diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/CHANGELOG.md b/sdk/apimanagement/azure-mgmt-apimanagement/CHANGELOG.md index 739f6db3a1ae..b1eda0af76c1 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/CHANGELOG.md +++ b/sdk/apimanagement/azure-mgmt-apimanagement/CHANGELOG.md @@ -1,5 +1,561 @@ # Release History +## 6.0.0b1 (2026-03-27) + +### Features Added + + - Client `ApiManagementClient` added parameter `cloud_setting` in method `__init__` + - Client `ApiManagementClient` added method `send_request` + - Client `ApiManagementClient` added operation group `api_tool` + - Client `ApiManagementClient` added operation group `api_gateway_hostname_binding` + - Client `ApiManagementClient` added operation group `client_application` + - Client `ApiManagementClient` added operation group `client_application_product_link` + - Model `AccessInformationContract` added property `system_data` + - Model `AllPoliciesContract` added property `system_data` + - Model `ApiContract` added property `properties` + - Model `ApiContract` added property `system_data` + - Model `ApiManagementGatewayConfigConnectionResource` added property `properties` + - Model `ApiManagementGatewayConfigConnectionResource` added property `system_data` + - Model `ApiManagementGatewayResource` added property `properties` + - Model `ApiManagementGatewayUpdateParameters` added property `properties` + - Model `ApiManagementServiceBaseProperties` added property `release_channel` + - Model `ApiManagementServiceBaseProperties` added property `zone_redundant` + - Model `ApiManagementServiceProperties` added property `release_channel` + - Model `ApiManagementServiceProperties` added property `zone_redundant` + - Model `ApiManagementServiceResource` added property `properties` + - Model `ApiManagementServiceUpdateParameters` added property `properties` + - Model `ApiManagementServiceUpdateProperties` added property `release_channel` + - Model `ApiManagementServiceUpdateProperties` added property `zone_redundant` + - Model `ApiManagementWorkspaceLinksResource` added property `properties` + - Model `ApiManagementWorkspaceLinksResource` added property `system_data` + - Model `ApiReleaseContract` added property `system_data` + - Model `ApiVersionSetContract` added property `properties` + - Model `ApiVersionSetContract` added property `system_data` + - Model `AssociationContract` added property `system_data` + - Model `AuthorizationAccessPolicyContract` added property `system_data` + - Model `AuthorizationContract` added property `system_data` + - Model `AuthorizationProviderContract` added property `system_data` + - Model `AuthorizationProviderOAuth2Settings` added property `key_vault` + - Model `AuthorizationServerContract` added property `properties` + - Model `AuthorizationServerContract` added property `system_data` + - Model `AuthorizationServerUpdateContract` added property `properties` + - Model `AuthorizationServerUpdateContract` added property `system_data` + - Model `BackendBaseParameters` added property `azure_region` + - Model `BackendBaseParametersPool` added property `failure_response` + - Model `BackendBaseParametersPool` added property `session_affinity` + - Model `BackendContract` added property `system_data` + - Model `BackendContractProperties` added property `azure_region` + - Model `BackendPool` added property `failure_response` + - Model `BackendPool` added property `session_affinity` + - Model `BackendPoolItem` added property `preferred_carbon_emission` + - Model `BackendReconnectContract` added property `properties` + - Model `BackendReconnectContract` added property `system_data` + - Model `BackendTlsProperties` added property `server_certificate_thumbprints` + - Model `BackendTlsProperties` added property `server_x509_names` + - Model `BackendUpdateParameterProperties` added property `azure_region` + - Model `CacheContract` added property `system_data` + - Model `CertificateContract` added property `system_data` + - Model `CircuitBreakerRule` added property `failure_response` + - Model `ContentItemContract` added property `system_data` + - Model `ContentTypeContract` added property `system_data` + - Model `DeletedServiceContract` added property `system_data` + - Model `DiagnosticContract` added property `system_data` + - Model `DiagnosticUpdateContract` added property `properties` + - Model `DiagnosticUpdateContract` added property `system_data` + - Model `DocumentationContract` added property `system_data` + - Model `EmailTemplateContract` added property `system_data` + - Model `GatewayCertificateAuthorityContract` added property `system_data` + - Model `GatewayContract` added property `identity` + - Model `GatewayContract` added property `system_data` + - Model `GatewayHostnameConfigurationContract` added property `system_data` + - Model `GlobalSchemaContract` added property `system_data` + - Model `GroupContract` added property `properties` + - Model `GroupContract` added property `system_data` + - Model `IdentityProviderContract` added property `properties` + - Model `IdentityProviderContract` added property `system_data` + - Model `IdentityProviderContractProperties` added property `certificate_id` + - Model `IdentityProviderCreateContract` added property `properties` + - Model `IdentityProviderCreateContract` added property `system_data` + - Model `IdentityProviderCreateContractProperties` added property `certificate_id` + - Model `IdentityProviderUpdateProperties` added property `certificate_id` + - Model `IssueAttachmentContract` added property `system_data` + - Model `IssueCommentContract` added property `system_data` + - Model `IssueContract` added property `properties` + - Model `IssueContract` added property `system_data` + - Model `LoggerContract` added property `system_data` + - Model `NamedValueContract` added property `properties` + - Model `NamedValueContract` added property `system_data` + - Model `NamedValueCreateContract` added property `properties` + - Model `NamedValueCreateContract` added property `system_data` + - Model `NotificationContract` added property `system_data` + - Model `OpenidConnectProviderContract` added property `system_data` + - Model `OperationContract` added property `properties` + - Model `OperationContract` added property `system_data` + - Model `OperationResultContract` added property `system_data` + - Model `PolicyContract` added property `system_data` + - Model `PolicyDescriptionContract` added property `system_data` + - Model `PolicyFragmentContract` added property `system_data` + - Model `PolicyRestrictionContract` added property `system_data` + - Model `PortalConfigContract` added property `properties` + - Model `PortalConfigContract` added property `system_data` + - Model `PortalDelegationSettings` added property `system_data` + - Model `PortalRevisionContract` added property `system_data` + - Model `PortalSettingsContract` added property `system_data` + - Model `PortalSigninSettings` added property `properties` + - Model `PortalSigninSettings` added property `system_data` + - Model `PortalSignupSettings` added property `system_data` + - Model `PrivateEndpointConnection` added property `system_data` + - Model `PrivateLinkResource` added property `system_data` + - Model `PrivateLinkResourceListResult` added property `next_link` + - Model `ProductApiLinkContract` added property `system_data` + - Model `ProductContract` added property `properties` + - Model `ProductContract` added property `system_data` + - Model `ProductContractProperties` added property `authentication_type` + - Model `ProductContractProperties` added property `application` + - Model `ProductEntityBaseParameters` added property `authentication_type` + - Model `ProductEntityBaseParameters` added property `application` + - Model `ProductGroupLinkContract` added property `system_data` + - Model `ProductTagResourceContractProperties` added property `authentication_type` + - Model `ProductTagResourceContractProperties` added property `application` + - Model `ProductUpdateProperties` added property `authentication_type` + - Model `ProductUpdateProperties` added property `application` + - Model `ProxyResource` added property `system_data` + - Model `RecipientEmailContract` added property `system_data` + - Model `RecipientUserContract` added property `properties` + - Model `RecipientUserContract` added property `system_data` + - Model `RemotePrivateEndpointConnectionWrapper` added property `properties` + - Model `ResolverContract` added property `properties` + - Model `ResolverContract` added property `system_data` + - Model `Resource` added property `system_data` + - Model `ResourceCollectionValueItem` added property `system_data` + - Model `SchemaContract` added property `system_data` + - Enum `SkuType` added member `PREMIUM_V2` + - Model `SubscriptionContract` added property `system_data` + - Model `TagApiLinkContract` added property `system_data` + - Model `TagContract` added property `system_data` + - Model `TagDescriptionContract` added property `properties` + - Model `TagDescriptionContract` added property `system_data` + - Model `TagOperationLinkContract` added property `system_data` + - Model `TagProductLinkContract` added property `system_data` + - Model `TenantConfigurationSyncStateContract` added property `system_data` + - Model `TenantSettingsContract` added property `system_data` + - Model `UserContract` added property `properties` + - Model `UserContract` added property `system_data` + - Model `WikiContract` added property `system_data` + - Model `WorkspaceContract` added property `system_data` + - Added model `AccessInformationCreateParameterProperties` + - Added model `AccessInformationUpdateParameterProperties` + - Added model `AuthorizationProviderKeyVaultContract` + - Added model `AuthorizationProviderKeyVaultCreateProperties` + - Added model `BackendFailureResponse` + - Added model `BackendReconnectProperties` + - Added model `BackendSessionAffinity` + - Added model `BackendSessionId` + - Added enum `BackendSessionIdSource` + - Added model `CacheUpdateProperties` + - Added enum `CarbonEmissionCategory` + - Added model `CertificateCreateOrUpdateProperties` + - Added model `ClientApplicationContract` + - Added model `ClientApplicationContractProperties` + - Added model `ClientApplicationProductLinkContract` + - Added model `ClientApplicationProductLinkContractProperties` + - Added model `ClientApplicationSecretsContract` + - Added model `ClientApplicationSecretsContractEntra` + - Added enum `ClientApplicationState` + - Added model `DeployConfigurationParameterProperties` + - Added model `DiagnosticContractUpdateProperties` + - Added model `EmailTemplateUpdateParameterProperties` + - Added model `GatewayConfigConnectionBaseProperties` + - Added model `GatewayHostnameBindingBaseProperties` + - Added model `GatewayHostnameBindingCertificate` + - Added model `GatewayHostnameBindingKeyVault` + - Added model `GatewayHostnameBindingKeyVaultLastStatus` + - Added model `GatewayHostnameBindingResource` + - Added model `GroupCreateParametersProperties` + - Added model `GroupUpdateParametersProperties` + - Added enum `KeyVaultFetchCode` + - Added model `LLMDiagnosticSettings` + - Added model `LLMMessageDiagnosticSettings` + - Added enum `LlmDiagnosticSettings` + - Added enum `LlmMessageLogTypes` + - Added model `LoggerUpdateParameters` + - Added model `ManagedServiceIdentity` + - Added enum `ManagedServiceIdentityType` + - Added model `OpenidConnectProviderUpdateContractProperties` + - Added model `PortalConfigProperties` + - Added model `PortalSigninSettingProperties` + - Added model `PrivateEndpointConnectionWrapperProperties` + - Added model `ProductApplicationContract` + - Added model `ProductApplicationContractEntra` + - Added enum `ProductAuthType` + - Added model `ProductEntityBaseParametersApplication` + - Added model `RecipientUsersContractProperties` + - Added enum `ReleaseChannel` + - Added model `ResolverEntityBaseContract` + - Added model `ResolverUpdateContractProperties` + - Added model `SaveConfigurationParameterProperties` + - Added model `SchemaDocumentProperties` + - Added model `SubscriptionCreateParameterProperties` + - Added model `SubscriptionUpdateParameterProperties` + - Added model `ToolContract` + - Added model `ToolContractProperties` + - Added model `TrackedResource` + - Added model `UserAssignedIdentity` + - Added model `UserTokenParameterProperties` + - Operation group `ApiManagementServiceOperations` added method `begin_refresh_hostnames` + - Operation group `AuthorizationProviderOperations` added method `refresh_secret` + - Added operation group `ApiGatewayHostnameBindingOperations` + - Added operation group `ApiToolOperations` + - Added operation group `ClientApplicationOperations` + - Added operation group `ClientApplicationProductLinkOperations` + - Model `AccessInformationCreateParameters` added property `properties` + - Model `AccessInformationUpdateParameters` added property `properties` + - Model `ApiUpdateContract` added property `properties` + - Model `ApiVersionSetUpdateParameters` added property `properties` + - Model `CacheUpdateParameters` added property `properties` + - Model `DeployConfigurationParameters` added property `properties` + - Model `DocumentationUpdateContract` added property `properties` + - Model `GroupCreateParameters` added property `properties` + - Model `GroupUpdateParameters` added property `properties` + - Model `IdentityProviderUpdateParameters` added property `properties` + - Model `IssueUpdateContract` added property `properties` + - Model `LoggerUpdateContract` added property `properties` + - Model `OpenidConnectProviderUpdateContract` added property `properties` + - Model `OperationUpdateContract` added property `properties` + - Model `PolicyRestrictionUpdateContract` added property `properties` + - Model `ProductUpdateParameters` added property `properties` + - Model `QuotaCounterValueUpdateContract` added property `properties` + - Model `ResolverUpdateContract` added property `properties` + - Model `SaveConfigurationParameter` added property `properties` + - Model `SubscriptionCreateParameters` added property `properties` + - Model `SubscriptionUpdateParameters` added property `properties` + - Model `TagCreateUpdateParameters` added property `properties` + - Model `TagDescriptionCreateParameters` added property `properties` + - Model `UserCreateParameters` added property `properties` + - Model `UserTokenParameters` added property `properties` + - Model `UserUpdateParameters` added property `properties` + - Model `WikiUpdateContract` added property `properties` + +### Breaking Changes + + - This version introduces new hybrid models which have dual dictionary and model nature. Please follow https://aka.ms/azsdk/python/migrate/hybrid-models for migration. + - For the method breakings, please refer to https://aka.ms/azsdk/python/migrate/operations for migration. + - Model `AccessInformationCreateParameters` moved instance variable `principal_id`, `primary_key`, `secondary_key` and `enabled` under property `properties` + - Model `AccessInformationUpdateParameters` moved instance variable `enabled` under property `properties` + - Model `ApiContract` moved instance variable `description`, `authentication_settings`, `subscription_key_parameter_names`, `api_type`, `api_revision`, `api_version`, `is_current`, `is_online`, `api_revision_description`, `api_version_description`, `api_version_set_id`, `subscription_required`, `terms_of_service_url`, `contact`, `license`, `source_api_id`, `display_name`, `service_url`, `path`, `protocols`, `api_version_set`, `provisioning_state` under property `properties` + - Model `ApiCreateOrUpdateParameter` moved instance variable `description`, `authentication_settings`, `subscription_key_parameter_names`, `api_type`, `api_revision`, `api_version`, `is_current`, `is_online`, `api_revision_description`, `api_version_description`, `api_version_set_id`, `subscription_required`, `terms_of_service_url`, `contact`, `license`, `source_api_id`, `display_name`, `service_url`, `path`, `protocols`, `api_version_set`, `provisioning_state`, `value`, `format`, `wsdl_selector`, `soap_api_type` and `translate_required_query_parameters_conduct` under property `properties` + - Model `ApiManagementGatewayConfigConnectionResource` moved instance variable `provisioning_state`, `source_id`, `default_hostname`, `hostnames` under property `properties` + - Model `ApiManagementGatewayResource` moved instance variable `provisioning_state`, `target_provisioning_state`, `created_at_utc`, `frontend`, `backend`, `configuration_api`, `virtual_network_type` under property `properties` + - Model `ApiManagementGatewayUpdateParameters` moved instance variable `provisioning_state`, `target_provisioning_state`, `created_at_utc`, `frontend`, `backend`, `configuration_api`, `virtual_network_type` under property `properties` + - Model `ApiManagementServiceResource` moved instance variable `notification_sender_email`, `provisioning_state`, `target_provisioning_state`, `created_at_utc`, `gateway_url`, `gateway_regional_url`, `portal_url`, `management_api_url`, `scm_url`, `developer_portal_url`, `hostname_configurations`, `public_ip_addresses`, `private_ip_addresses`, `public_ip_address_id`, `public_network_access`, `configuration_api`, `virtual_network_configuration`, `additional_locations`, `custom_properties`, `certificates`, `enable_client_certificate`, `nat_gateway_state`, `outbound_public_ip_addresses`, `disable_gateway`, `virtual_network_type`, `api_version_constraint`, `restore`, `private_endpoint_connections`, `platform_version`, `legacy_portal_status`, `developer_portal_status`, `publisher_email`, `publisher_name` under property `properties` + - Model `ApiManagementServiceUpdateParameters` moved instance variable `notification_sender_email`, `provisioning_state`, `target_provisioning_state`, `created_at_utc`, `gateway_url`, `gateway_regional_url`, `portal_url`, `management_api_url`, `scm_url`, `developer_portal_url`, `hostname_configurations`, `public_ip_addresses`, `private_ip_addresses`, `public_ip_address_id`, `public_network_access`, `configuration_api`, `virtual_network_configuration`, `additional_locations`, `custom_properties`, `certificates`, `enable_client_certificate`, `nat_gateway_state`, `outbound_public_ip_addresses`, `disable_gateway`, `virtual_network_type`, `api_version_constraint`, `restore`, `private_endpoint_connections`, `platform_version`, `legacy_portal_status`, `developer_portal_status`, `publisher_email`, `publisher_name` under property `properties` + - Model `ApiManagementSkuRestrictions` renamed its instance variable `values` to `values_property` + - Model `ApiManagementWorkspaceLinksResource` moved instance variable `workspace_id`, `gateways` under property `properties` + - Model `ApiUpdateContract` moved instance variable `description`, `authentication_settings`, `subscription_key_parameter_names`, `api_type`, `api_revision`, `api_version`, `is_current`, `is_online`, `api_revision_description`, `api_version_description`, `api_version_set_id`, `subscription_required`, `terms_of_service_url`, `contact`, `license`, `display_name`, `service_url`, `path` and `protocols` under property `properties` + - Model `ApiVersionSetContract` moved instance variable `description`, `version_query_name`, `version_header_name`, `display_name`, `versioning_scheme` under property `properties` + - Model `ApiVersionSetUpdateParameters` moved instance variable `description`, `version_query_name`, `version_header_name`, `display_name` and `versioning_scheme` under property `properties` + - Model `AuthorizationServerContract` moved instance variable `description`, `authorization_methods`, `client_authentication_method`, `token_body_parameters`, `token_endpoint`, `support_state`, `default_scope`, `bearer_token_sending_methods`, `resource_owner_username`, `resource_owner_password`, `display_name`, `use_in_test_console`, `use_in_api_documentation`, `client_registration_endpoint`, `authorization_endpoint`, `grant_types`, `client_id`, `client_secret` under property `properties` + - Model `AuthorizationServerUpdateContract` moved instance variable `description`, `authorization_methods`, `client_authentication_method`, `token_body_parameters`, `token_endpoint`, `support_state`, `default_scope`, `bearer_token_sending_methods`, `resource_owner_username`, `resource_owner_password`, `display_name`, `use_in_test_console`, `use_in_api_documentation`, `client_registration_endpoint`, `authorization_endpoint`, `grant_types`, `client_id`, `client_secret` under property `properties` + - Model `BackendContract` moved instance variable `title`, `description`, `resource_id`, `credentials`, `proxy`, `tls`, `circuit_breaker`, `pool`, `type_properties_type`, `url` and `protocol` under property `properties` + - Model `BackendReconnectContract` moved instance variable `after` under property `properties` + - Model `BackendUpdateParameters` moved instance variable `title`, `description`, `resource_id`, `credentials`, `proxy`, `tls`, `circuit_breaker`, `pool`, `type`, `url` and `protocol` under property `properties` + - Model `CacheUpdateParameters` moved instance variable `description`, `connection_string`, `use_from_location` and `resource_id` under property `properties` + - Model `CertificateCreateOrUpdateParameters` moved instance variable `data`, `password` and `key_vault` under property `properties` + - Model `DeployConfigurationParameters` moved instance variable `branch` and `force` under property `properties` + - Model `DiagnosticUpdateContract` moved instance variable `always_log`, `logger_id`, `sampling`, `frontend`, `backend`, `log_client_ip`, `http_correlation_protocol`, `verbosity`, `operation_name_format`, `metrics` under property `properties` + - Model `DocumentationUpdateContract` moved instance variable `title` and `content` under property `properties` + - Model `EmailTemplateUpdateParameters` moved instance variable `subject`, `title`, `description`, `body` and `parameters` under property `properties` + - Model `GroupContract` moved instance variable `display_name`, `description`, `built_in`, `type_properties_type`, `external_id` under property `properties` + - Model `GroupCreateParameters` moved instance variable `display_name`, `description`, `type` and `external_id` under property `properties` + - Model `GroupUpdateParameters` moved instance variable `display_name`, `description`, `type` and `external_id` under property `properties` + - Model `IdentityProviderContract` moved instance variable `type_properties_type`, `signin_tenant`, `allowed_tenants`, `authority`, `signup_policy_name`, `signin_policy_name`, `profile_editing_policy_name`, `password_reset_policy_name`, `client_library`, `client_id`, `client_secret` under property `properties` + - Model `IdentityProviderCreateContract` moved instance variable `type_properties_type`, `signin_tenant`, `allowed_tenants`, `authority`, `signup_policy_name`, `signin_policy_name`, `profile_editing_policy_name`, `password_reset_policy_name`, `client_library`, `client_id`, `client_secret` under property `properties` + - Model `IdentityProviderUpdateParameters` moved instance variable `type`, `signin_tenant`, `allowed_tenants`, `authority`, `signup_policy_name`, `signin_policy_name`, `profile_editing_policy_name`, `password_reset_policy_name`, `client_library`, `client_id` and `client_secret` under property `properties` + - Model `IssueContract` moved instance variable `created_date`, `state`, `api_id`, `title`, `description`, `user_id` under property `properties` + - Model `IssueUpdateContract` moved instance variable `created_date`, `state`, `api_id`, `title`, `description` and `user_id` under property `properties` + - Model `LoggerUpdateContract` moved instance variable `logger_type`, `description`, `credentials` and `is_buffered` under property `properties` + - Model `NamedValueContract` moved instance variable `tags`, `secret`, `display_name`, `value`, `key_vault`, `provisioning_state` under property `properties` + - Model `NamedValueCreateContract` moved instance variable `tags`, `secret`, `display_name`, `value`, `key_vault` under property `properties` + - Model `NamedValueUpdateParameters` moved instance variable `tags`, `secret`, `display_name`, `value` and `key_vault` under property `properties` + - Model `OpenidConnectProviderUpdateContract` moved instance variable `display_name`, `description`, `metadata_endpoint`, `client_id`, `client_secret`, `use_in_test_console` and `use_in_api_documentation` under property `properties` + - Model `OperationContract` moved instance variable `template_parameters`, `description`, `request`, `responses`, `policies`, `display_name`, `method`, `url_template` under property `properties` + - Model `OperationStatusResult` deleted or renamed its instance variable `resource_id` + - Model `OperationUpdateContract` moved instance variable `template_parameters`, `description`, `request`, `responses`, `policies`, `display_name`, `method` and `url_template` under property `properties` + - Model `ParameterContract` renamed its instance variable `values` to `values_property` + - Model `PolicyRestrictionUpdateContract` moved instance variable `scope` and `require_base` under property `properties` + - Model `PortalConfigContract` moved instance variable `enable_basic_auth`, `signin`, `signup`, `delegation`, `cors`, `csp` under property `properties` + - Model `PortalSigninSettings` moved instance variable `enabled` under property `properties` + - Model `ProductContract` moved instance variable `description`, `terms`, `subscription_required`, `approval_required`, `subscriptions_limit`, `state`, `display_name` under property `properties` + - Model `ProductUpdateParameters` moved instance variable `description`, `terms`, `subscription_required`, `approval_required`, `subscriptions_limit`, `state` and `display_name` under property `properties` + - Model `QuotaCounterValueUpdateContract` moved instance variable `calls_count` and `kb_transferred` under property `properties` + - Model `RecipientUserContract` moved instance variable `user_id` under property `properties` + - Model `RemotePrivateEndpointConnectionWrapper` moved instance variable `private_endpoint`, `private_link_service_connection_state`, `provisioning_state`, `group_ids` under property `properties` + - Model `ResolverContract` moved instance variable `display_name`, `path`, `description` under property `properties` + - Model `ResolverUpdateContract` moved instance variable `display_name`, `path` and `description` under property `properties` + - Model `SaveConfigurationParameter` moved instance variable `branch` and `force` under property `properties` + - Model `SubscriptionCreateParameters` moved instance variable `owner_id`, `scope`, `display_name`, `primary_key`, `secondary_key`, `state` and `allow_tracing` under property `properties` + - Model `SubscriptionUpdateParameters` moved instance variable `owner_id`, `scope`, `expiration_date`, `display_name`, `primary_key`, `secondary_key`, `state`, `state_comment` and `allow_tracing` under property `properties` + - Model `TagCreateUpdateParameters` moved instance variable `display_name` under property `properties` + - Model `TagDescriptionContract` moved instance variable `description`, `external_docs_url`, `external_docs_description`, `tag_id`, `display_name` under property `properties` + - Model `TagDescriptionCreateParameters` moved instance variable `description`, `external_docs_url` and `external_docs_description` under property `properties` + - Model `UserContract` moved instance variable `state`, `note`, `identities`, `first_name`, `last_name`, `email`, `registration_date`, `groups` under property `properties` + - Model `UserCreateParameters` moved instance variable `state`, `note`, `identities`, `email`, `first_name`, `last_name`, `password`, `app_type` and `confirmation` under property `properties` + - Model `UserTokenParameters` moved instance variable `key_type` and `expiry` under property `properties` + - Model `UserUpdateParameters` moved instance variable `state`, `note`, `identities`, `email`, `password`, `first_name` and `last_name` under property `properties` + - Model `WikiUpdateContract` moved instance variable `documents` under property `properties` + - Deleted or renamed model `ApiRevisionInfoContract` + - Deleted or renamed model `AsyncResolverStatus` + - Deleted or renamed model `PolicyWithComplianceContract` + - Deleted or renamed model `QuotaCounterValueContract` + - Deleted or renamed model `ResolverResultContract` + - Deleted or renamed model `ResolverResultLogItemContract` + - Deleted or renamed model `ApiManagementClientOperationsMixin` + - Method `ApiDiagnosticOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiDiagnosticOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiDiagnosticOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiGatewayConfigConnectionOperations.begin_delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiIssueAttachmentOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiIssueAttachmentOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiIssueCommentOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiIssueCommentOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiIssueOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiIssueOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiIssueOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiOperationOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiOperationOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiOperationOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiOperationPolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiOperationPolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiOperations.begin_delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiPolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiPolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiReleaseOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiReleaseOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiReleaseOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiSchemaOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiSchemaOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiTagDescriptionOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiTagDescriptionOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiVersionSetOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiVersionSetOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiVersionSetOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiWikiOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiWikiOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiWikiOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `AuthorizationAccessPolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `AuthorizationAccessPolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `AuthorizationOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `AuthorizationOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `AuthorizationProviderOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `AuthorizationProviderOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `AuthorizationServerOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `AuthorizationServerOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `AuthorizationServerOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `BackendOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `BackendOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `BackendOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `CacheOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `CacheOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `CacheOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `CertificateOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `CertificateOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ContentItemOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ContentItemOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ContentTypeOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ContentTypeOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `DelegationSettingsOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `DelegationSettingsOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `DiagnosticOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `DiagnosticOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `DiagnosticOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `DocumentationOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `DocumentationOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `DocumentationOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `EmailTemplateOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `EmailTemplateOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `EmailTemplateOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GatewayCertificateAuthorityOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GatewayCertificateAuthorityOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GatewayHostnameConfigurationOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GatewayHostnameConfigurationOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GatewayOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GatewayOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GatewayOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GlobalSchemaOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GlobalSchemaOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GraphQLApiResolverOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GraphQLApiResolverOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GraphQLApiResolverOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GraphQLApiResolverPolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GraphQLApiResolverPolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GroupOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GroupOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `GroupOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `IdentityProviderOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `IdentityProviderOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `IdentityProviderOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `LoggerOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `LoggerOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `LoggerOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `NamedValueOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `NamedValueOperations.begin_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `NamedValueOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `NotificationOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `OpenIdConnectProviderOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `OpenIdConnectProviderOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `OpenIdConnectProviderOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PolicyFragmentOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PolicyFragmentOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PolicyRestrictionOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PolicyRestrictionOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PolicyRestrictionOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PortalConfigOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PortalConfigOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `PortalRevisionOperations.begin_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ProductOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ProductOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ProductOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ProductPolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ProductPolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ProductWikiOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ProductWikiOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ProductWikiOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `SignInSettingsOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `SignInSettingsOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `SignUpSettingsOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `SignUpSettingsOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `SubscriptionOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `SubscriptionOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `SubscriptionOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `TagOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `TagOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `TagOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `TenantAccessOperations.create` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `TenantAccessOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `UserOperations.begin_delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `UserOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `UserOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiDiagnosticOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiDiagnosticOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiDiagnosticOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiOperationOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiOperationOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiOperationOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiOperationPolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiOperationPolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiPolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiPolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiReleaseOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiReleaseOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiReleaseOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiSchemaOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiSchemaOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiVersionSetOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiVersionSetOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceApiVersionSetOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceBackendOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceBackendOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceBackendOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceCertificateOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceCertificateOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceDiagnosticOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceDiagnosticOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceDiagnosticOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceGlobalSchemaOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceGlobalSchemaOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceGroupOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceGroupOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceGroupOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceLoggerOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceLoggerOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceLoggerOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceNamedValueOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceNamedValueOperations.begin_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceNamedValueOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceNotificationOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspacePolicyFragmentOperations.begin_create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspacePolicyFragmentOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspacePolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspacePolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceProductOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceProductOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceProductOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceProductPolicyOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceProductPolicyOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceSubscriptionOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceSubscriptionOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceSubscriptionOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceTagOperations.create_or_update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceTagOperations.delete` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `WorkspaceTagOperations.update` replaced positional_or_keyword parameter `if_match` to keyword_only parameter `etag`/`match_condition` + - Method `ApiExportOperations.get` changed its parameter `format`/`export` from `positional_or_keyword` to `keyword_only` + - Method `ApiIssueOperations.get` changed its parameter `expand_comments_attachments` from `positional_or_keyword` to `keyword_only` + - Method `ApiIssueOperations.list_by_service` changed its parameter `expand_comments_attachments` from `positional_or_keyword` to `keyword_only` + - Method `ApiOperationOperations.list_by_api` changed its parameter `tags` from `positional_or_keyword` to `keyword_only` + - Method `ApiOperationPolicyOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `ApiOperations.list_by_service` changed its parameter `tags`/`expand_api_version_set` from `positional_or_keyword` to `keyword_only` + - Method `ApiOperations.list_by_tags` changed its parameter `include_not_tagged_apis` from `positional_or_keyword` to `keyword_only` + - Method `ApiPolicyOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `CertificateOperations.list_by_service` changed its parameter `is_key_vault_refresh_failed` from `positional_or_keyword` to `keyword_only` + - Method `GraphQLApiResolverPolicyOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `NamedValueOperations.list_by_service` changed its parameter `is_key_vault_refresh_failed` from `positional_or_keyword` to `keyword_only` + - Method `OperationOperations.list_by_tags` changed its parameter `include_not_tagged_operations` from `positional_or_keyword` to `keyword_only` + - Method `PolicyDescriptionOperations.list_by_service` changed its parameter `scope` from `positional_or_keyword` to `keyword_only` + - Method `PolicyFragmentOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `PolicyFragmentOperations.list_by_service` changed its parameter `orderby` from `positional_or_keyword` to `keyword_only` + - Method `PolicyOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `ProductOperations.list_by_service` changed its parameter `expand_groups`/`tags` from `positional_or_keyword` to `keyword_only` + - Method `ProductOperations.list_by_tags` changed its parameter `include_not_tagged_products` from `positional_or_keyword` to `keyword_only` + - Method `ProductPolicyOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `ReportsOperations.list_by_api` changed its parameter `orderby` from `positional_or_keyword` to `keyword_only` + - Method `ReportsOperations.list_by_operation` changed its parameter `orderby` from `positional_or_keyword` to `keyword_only` + - Method `ReportsOperations.list_by_product` changed its parameter `orderby` from `positional_or_keyword` to `keyword_only` + - Method `ReportsOperations.list_by_subscription` changed its parameter `orderby` from `positional_or_keyword` to `keyword_only` + - Method `ReportsOperations.list_by_time` changed its parameter `interval`/`orderby` from `positional_or_keyword` to `keyword_only` + - Method `ReportsOperations.list_by_user` changed its parameter `orderby` from `positional_or_keyword` to `keyword_only` + - Method `TagOperations.list_by_service` changed its parameter `scope` from `positional_or_keyword` to `keyword_only` + - Method `UserConfirmationPasswordOperations.send` changed its parameter `app_type` from `positional_or_keyword` to `keyword_only` + - Method `UserOperations.list_by_service` changed its parameter `expand_groups` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceApiExportOperations.get` changed its parameter `format`/`export` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceApiOperationOperations.list_by_api` changed its parameter `tags` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceApiOperationPolicyOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceApiOperations.list_by_service` changed its parameter `tags`/`expand_api_version_set` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceApiPolicyOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceCertificateOperations.list_by_workspace` changed its parameter `is_key_vault_refresh_failed` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceNamedValueOperations.list_by_service` changed its parameter `is_key_vault_refresh_failed` from `positional_or_keyword` to `keyword_only` + - Method `WorkspacePolicyFragmentOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `WorkspacePolicyFragmentOperations.list_by_service` changed its parameter `orderby` from `positional_or_keyword` to `keyword_only` + - Method `WorkspacePolicyOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceProductOperations.list_by_service` changed its parameter `expand_groups`/`tags` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceProductPolicyOperations.get` changed its parameter `format` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceTagOperations.list_by_service` changed its parameter `scope` from `positional_or_keyword` to `keyword_only` + - Method `ApiOperations.begin_delete` changed its parameter `delete_revisions` from `positional_or_keyword` to `keyword_only` + - Method `ApiSchemaOperations.delete` changed its parameter `force` from `positional_or_keyword` to `keyword_only` + - Method `ProductOperations.delete` changed its parameter `delete_subscriptions` from `positional_or_keyword` to `keyword_only` + - Method `SubscriptionOperations.create_or_update` changed its parameter `notify`/`app_type` from `positional_or_keyword` to `keyword_only` + - Method `SubscriptionOperations.update` changed its parameter `notify`/`app_type` from `positional_or_keyword` to `keyword_only` + - Method `UserOperations.begin_delete` changed its parameter `delete_subscriptions`/`notify`/`app_type` from `positional_or_keyword` to `keyword_only` + - Method `UserOperations.create_or_update` changed its parameter `notify` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceApiOperations.delete` changed its parameter `delete_revisions` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceApiSchemaOperations.delete` changed its parameter `force` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceProductOperations.delete` changed its parameter `delete_subscriptions` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceSubscriptionOperations.create_or_update` changed its parameter `notify`/`app_type` from `positional_or_keyword` to `keyword_only` + - Method `WorkspaceSubscriptionOperations.update` changed its parameter `notify`/`app_type` from `positional_or_keyword` to `keyword_only` + +### Other Changes + + - Deleted model `AccessInformationCollection`/`AllPoliciesCollection`/`ApiCollection`/`ApiManagementSkusResult`/`ApiReleaseCollection`/`ApiRevisionCollection`/`ApiVersionSetCollection`/`AuthorizationAccessPolicyCollection`/`AuthorizationCollection`/`AuthorizationProviderCollection`/`AuthorizationServerCollection`/`BackendCollection`/`CacheCollection`/`CertificateCollection`/`ContentItemCollection`/`ContentTypeCollection`/`DeletedServicesCollection`/`DiagnosticCollection`/`DocumentationCollection`/`EmailTemplateCollection`/`GatewayCertificateAuthorityCollection`/`GatewayCollection`/`GatewayHostnameConfigurationCollection`/`GatewayResourceSkuResults`/`GlobalSchemaCollection`/`GroupCollection`/`IdentityProviderList`/`IssueAttachmentCollection`/`IssueCollection`/`IssueCommentCollection`/`LoggerCollection`/`NamedValueCollection`/`NotificationCollection`/`OpenIdConnectProviderCollection`/`OperationCollection`/`PolicyFragmentCollection`/`PolicyRestrictionCollection`/`PolicyWithComplianceCollection`/`PortalConfigCollection`/`PortalRevisionCollection`/`ProductApiLinkCollection`/`ProductCollection`/`ProductGroupLinkCollection`/`ReportCollection`/`RequestReportCollection`/`ResolverCollection`/`ResourceSkuResults`/`SchemaCollection`/`SubscriptionCollection`/`TagApiLinkCollection`/`TagCollection`/`TagDescriptionCollection`/`TagOperationLinkCollection`/`TagProductLinkCollection`/`TagResourceCollection`/`TenantSettingsCollection`/`UserCollection`/`UserIdentityCollection`/`WikiCollection`/`WorkspaceCollection` which actually were not used by SDK users + ## 5.0.0 (2025-04-21) ### Features Added diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/MANIFEST.in b/sdk/apimanagement/azure-mgmt-apimanagement/MANIFEST.in index affab11e25d5..286c837ed7bc 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/MANIFEST.in +++ b/sdk/apimanagement/azure-mgmt-apimanagement/MANIFEST.in @@ -1,8 +1,7 @@ -include _meta.json -recursive-include tests *.py *.json -recursive-include samples *.py *.md include *.md -include azure/__init__.py -include azure/mgmt/__init__.py include LICENSE include azure/mgmt/apimanagement/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include azure/__init__.py +include azure/mgmt/__init__.py diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/README.md b/sdk/apimanagement/azure-mgmt-apimanagement/README.md index 636f35053de7..0fd2ec3ff983 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/README.md +++ b/sdk/apimanagement/azure-mgmt-apimanagement/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure API Management Client Library. -This package has been tested with Python 3.8+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.8+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json b/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json deleted file mode 100644 index d5a550d086a4..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "7c1e8a2c1e18ac0dd65b88f00447992ed86fcc0f", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.27.4", - "@autorest/modelerfour@4.27.0" - ], - "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/azure-sdk-for-python/sdk --tag=package-2024-05 --use=@autorest/python@6.27.4 --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/_metadata.json b/sdk/apimanagement/azure-mgmt-apimanagement/_metadata.json new file mode 100644 index 000000000000..a246cc703e32 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/_metadata.json @@ -0,0 +1,10 @@ +{ + "apiVersion": "2025-03-01-preview", + "apiVersions": { + "Microsoft.ApiManagement": "2025-03-01-preview" + }, + "commit": "5038b362fae5e6f54bb6fe7e0a0d18370a946acf", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "typespec_src": "specification/apimanagement/resource-manager/Microsoft.ApiManagement/ApiManagement", + "emitterVersion": "0.61.2" +} \ No newline at end of file diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/apiview-properties.json b/sdk/apimanagement/azure-mgmt-apimanagement/apiview-properties.json new file mode 100644 index 000000000000..39c18f6f4923 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/apiview-properties.json @@ -0,0 +1,1787 @@ +{ + "CrossLanguagePackageId": "Microsoft.ApiManagement", + "CrossLanguageDefinitionId": { + "azure.mgmt.apimanagement.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.apimanagement.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.apimanagement.models.AccessInformationContract": "Microsoft.ApiManagement.AccessInformationContract", + "azure.mgmt.apimanagement.models.AccessInformationContractProperties": "Microsoft.ApiManagement.AccessInformationContractProperties", + "azure.mgmt.apimanagement.models.AccessInformationCreateParameterProperties": "Microsoft.ApiManagement.AccessInformationCreateParameterProperties", + "azure.mgmt.apimanagement.models.AccessInformationCreateParameters": "Microsoft.ApiManagement.AccessInformationCreateParameters", + "azure.mgmt.apimanagement.models.AccessInformationSecretsContract": "Microsoft.ApiManagement.AccessInformationSecretsContract", + "azure.mgmt.apimanagement.models.AccessInformationUpdateParameterProperties": "Microsoft.ApiManagement.AccessInformationUpdateParameterProperties", + "azure.mgmt.apimanagement.models.AccessInformationUpdateParameters": "Microsoft.ApiManagement.AccessInformationUpdateParameters", + "azure.mgmt.apimanagement.models.AdditionalLocation": "Microsoft.ApiManagement.AdditionalLocation", + "azure.mgmt.apimanagement.models.AllPoliciesContract": "Microsoft.ApiManagement.AllPoliciesContract", + "azure.mgmt.apimanagement.models.AllPoliciesContractProperties": "Microsoft.ApiManagement.AllPoliciesContractProperties", + "azure.mgmt.apimanagement.models.ApiContactInformation": "Microsoft.ApiManagement.ApiContactInformation", + "azure.mgmt.apimanagement.models.ApiContract": "Microsoft.ApiManagement.ApiContract", + "azure.mgmt.apimanagement.models.ApiEntityBaseContract": "Microsoft.ApiManagement.ApiEntityBaseContract", + "azure.mgmt.apimanagement.models.ApiContractProperties": "Microsoft.ApiManagement.ApiContractProperties", + "azure.mgmt.apimanagement.models.ApiContractUpdateProperties": "Microsoft.ApiManagement.ApiContractUpdateProperties", + "azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter": "Microsoft.ApiManagement.ApiCreateOrUpdateParameter", + "azure.mgmt.apimanagement.models.ApiCreateOrUpdateProperties": "Microsoft.ApiManagement.ApiCreateOrUpdateProperties", + "azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector": "Microsoft.ApiManagement.ApiCreateOrUpdatePropertiesWsdlSelector", + "azure.mgmt.apimanagement.models.ApiExportResult": "Microsoft.ApiManagement.ApiExportResult", + "azure.mgmt.apimanagement.models.ApiExportResultValue": "Microsoft.ApiManagement.ApiExportResultValue", + "azure.mgmt.apimanagement.models.ApiLicenseInformation": "Microsoft.ApiManagement.ApiLicenseInformation", + "azure.mgmt.apimanagement.models.ApiManagementGatewayBaseProperties": "Microsoft.ApiManagement.ApiManagementGatewayBaseProperties", + "azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource": "Microsoft.ApiManagement.ApiManagementGatewayConfigConnectionResource", + "azure.mgmt.apimanagement.models.ApiManagementGatewayProperties": "Microsoft.ApiManagement.ApiManagementGatewayProperties", + "azure.mgmt.apimanagement.models.TrackedResource": "Azure.ResourceManager.CommonTypes.TrackedResource", + "azure.mgmt.apimanagement.models.ApiManagementGatewayResource": "Microsoft.ApiManagement.ApiManagementGatewayResource", + "azure.mgmt.apimanagement.models.ApiManagementGatewaySkuProperties": "Microsoft.ApiManagement.ApiManagementGatewaySkuProperties", + "azure.mgmt.apimanagement.models.ApiManagementGatewaySkuPropertiesForPatch": "Microsoft.ApiManagement.ApiManagementGatewaySkuPropertiesForPatch", + "azure.mgmt.apimanagement.models.ApimResource": "Microsoft.ApiManagement.ApimResource", + "azure.mgmt.apimanagement.models.ApiManagementGatewayUpdateParameters": "Microsoft.ApiManagement.ApiManagementGatewayUpdateParameters", + "azure.mgmt.apimanagement.models.ApiManagementGatewayUpdateProperties": "Microsoft.ApiManagement.ApiManagementGatewayUpdateProperties", + "azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters": "Microsoft.ApiManagement.ApiManagementServiceApplyNetworkConfigurationParameters", + "azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters": "Microsoft.ApiManagement.ApiManagementServiceBackupRestoreParameters", + "azure.mgmt.apimanagement.models.ApiManagementServiceBaseProperties": "Microsoft.ApiManagement.ApiManagementServiceBaseProperties", + "azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters": "Microsoft.ApiManagement.ApiManagementServiceCheckNameAvailabilityParameters", + "azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult": "Microsoft.ApiManagement.ApiManagementServiceGetDomainOwnershipIdentifierResult", + "azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult": "Microsoft.ApiManagement.ApiManagementServiceGetSsoTokenResult", + "azure.mgmt.apimanagement.models.ApiManagementServiceIdentity": "Microsoft.ApiManagement.ApiManagementServiceIdentity", + "azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult": "Microsoft.ApiManagement.ApiManagementServiceNameAvailabilityResult", + "azure.mgmt.apimanagement.models.ApiManagementServiceProperties": "Microsoft.ApiManagement.ApiManagementServiceProperties", + "azure.mgmt.apimanagement.models.ApiManagementServiceResource": "Microsoft.ApiManagement.ApiManagementServiceResource", + "azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties": "Microsoft.ApiManagement.ApiManagementServiceSkuProperties", + "azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters": "Microsoft.ApiManagement.ApiManagementServiceUpdateParameters", + "azure.mgmt.apimanagement.models.ApiManagementServiceUpdateProperties": "Microsoft.ApiManagement.ApiManagementServiceUpdateProperties", + "azure.mgmt.apimanagement.models.ApiManagementSku": "Microsoft.ApiManagement.ApiManagementSku", + "azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities": "Microsoft.ApiManagement.ApiManagementSkuCapabilities", + "azure.mgmt.apimanagement.models.ApiManagementSkuCapacity": "Microsoft.ApiManagement.ApiManagementSkuCapacity", + "azure.mgmt.apimanagement.models.ApiManagementSkuCosts": "Microsoft.ApiManagement.ApiManagementSkuCosts", + "azure.mgmt.apimanagement.models.ApiManagementSkuLocationInfo": "Microsoft.ApiManagement.ApiManagementSkuLocationInfo", + "azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionInfo": "Microsoft.ApiManagement.ApiManagementSkuRestrictionInfo", + "azure.mgmt.apimanagement.models.ApiManagementSkuRestrictions": "Microsoft.ApiManagement.ApiManagementSkuRestrictions", + "azure.mgmt.apimanagement.models.ApiManagementSkuZoneDetails": "Microsoft.ApiManagement.ApiManagementSkuZoneDetails", + "azure.mgmt.apimanagement.models.WorkspaceLinksBaseProperties": "Microsoft.ApiManagement.WorkspaceLinksBaseProperties", + "azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksProperties": "Microsoft.ApiManagement.ApiManagementWorkspaceLinksProperties", + "azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource": "Microsoft.ApiManagement.ApiManagementWorkspaceLinksResource", + "azure.mgmt.apimanagement.models.ApiReleaseContract": "Microsoft.ApiManagement.ApiReleaseContract", + "azure.mgmt.apimanagement.models.ApiReleaseContractProperties": "Microsoft.ApiManagement.ApiReleaseContractProperties", + "azure.mgmt.apimanagement.models.ApiRevisionContract": "Microsoft.ApiManagement.ApiRevisionContract", + "azure.mgmt.apimanagement.models.ApiTagResourceContractProperties": "Microsoft.ApiManagement.ApiTagResourceContractProperties", + "azure.mgmt.apimanagement.models.ApiUpdateContract": "Microsoft.ApiManagement.ApiUpdateContract", + "azure.mgmt.apimanagement.models.ApiVersionConstraint": "Microsoft.ApiManagement.ApiVersionConstraint", + "azure.mgmt.apimanagement.models.ApiVersionSetContract": "Microsoft.ApiManagement.ApiVersionSetContract", + "azure.mgmt.apimanagement.models.ApiVersionSetContractDetails": "Microsoft.ApiManagement.ApiVersionSetContractDetails", + "azure.mgmt.apimanagement.models.ApiVersionSetEntityBase": "Microsoft.ApiManagement.ApiVersionSetEntityBase", + "azure.mgmt.apimanagement.models.ApiVersionSetContractProperties": "Microsoft.ApiManagement.ApiVersionSetContractProperties", + "azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters": "Microsoft.ApiManagement.ApiVersionSetUpdateParameters", + "azure.mgmt.apimanagement.models.ApiVersionSetUpdateParametersProperties": "Microsoft.ApiManagement.ApiVersionSetUpdateParametersProperties", + "azure.mgmt.apimanagement.models.ArmIdWrapper": "Microsoft.ApiManagement.ArmIdWrapper", + "azure.mgmt.apimanagement.models.AssociationContract": "Microsoft.ApiManagement.AssociationContract", + "azure.mgmt.apimanagement.models.AssociationContractProperties": "Microsoft.ApiManagement.AssociationContractProperties", + "azure.mgmt.apimanagement.models.AuthenticationSettingsContract": "Microsoft.ApiManagement.AuthenticationSettingsContract", + "azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract": "Microsoft.ApiManagement.AuthorizationAccessPolicyContract", + "azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContractProperties": "Microsoft.ApiManagement.AuthorizationAccessPolicyContractProperties", + "azure.mgmt.apimanagement.models.AuthorizationConfirmConsentCodeRequestContract": "Microsoft.ApiManagement.AuthorizationConfirmConsentCodeRequestContract", + "azure.mgmt.apimanagement.models.AuthorizationContract": "Microsoft.ApiManagement.AuthorizationContract", + "azure.mgmt.apimanagement.models.AuthorizationContractProperties": "Microsoft.ApiManagement.AuthorizationContractProperties", + "azure.mgmt.apimanagement.models.AuthorizationError": "Microsoft.ApiManagement.AuthorizationError", + "azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract": "Microsoft.ApiManagement.AuthorizationLoginRequestContract", + "azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract": "Microsoft.ApiManagement.AuthorizationLoginResponseContract", + "azure.mgmt.apimanagement.models.AuthorizationProviderContract": "Microsoft.ApiManagement.AuthorizationProviderContract", + "azure.mgmt.apimanagement.models.AuthorizationProviderContractProperties": "Microsoft.ApiManagement.AuthorizationProviderContractProperties", + "azure.mgmt.apimanagement.models.AuthorizationProviderKeyVaultCreateProperties": "Microsoft.ApiManagement.AuthorizationProviderKeyVaultCreateProperties", + "azure.mgmt.apimanagement.models.AuthorizationProviderKeyVaultContract": "Microsoft.ApiManagement.AuthorizationProviderKeyVaultContract", + "azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2GrantTypes": "Microsoft.ApiManagement.AuthorizationProviderOAuth2GrantTypes", + "azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2Settings": "Microsoft.ApiManagement.AuthorizationProviderOAuth2Settings", + "azure.mgmt.apimanagement.models.AuthorizationServerContract": "Microsoft.ApiManagement.AuthorizationServerContract", + "azure.mgmt.apimanagement.models.AuthorizationServerContractBaseProperties": "Microsoft.ApiManagement.AuthorizationServerContractBaseProperties", + "azure.mgmt.apimanagement.models.AuthorizationServerContractProperties": "Microsoft.ApiManagement.AuthorizationServerContractProperties", + "azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract": "Microsoft.ApiManagement.AuthorizationServerSecretsContract", + "azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract": "Microsoft.ApiManagement.AuthorizationServerUpdateContract", + "azure.mgmt.apimanagement.models.AuthorizationServerUpdateContractProperties": "Microsoft.ApiManagement.AuthorizationServerUpdateContractProperties", + "azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials": "Microsoft.ApiManagement.BackendAuthorizationHeaderCredentials", + "azure.mgmt.apimanagement.models.BackendBaseParameters": "Microsoft.ApiManagement.BackendBaseParameters", + "azure.mgmt.apimanagement.models.BackendPool": "Microsoft.ApiManagement.BackendPool", + "azure.mgmt.apimanagement.models.BackendBaseParametersPool": "Microsoft.ApiManagement.BackendBaseParametersPool", + "azure.mgmt.apimanagement.models.BackendCircuitBreaker": "Microsoft.ApiManagement.BackendCircuitBreaker", + "azure.mgmt.apimanagement.models.BackendConfiguration": "Microsoft.ApiManagement.BackendConfiguration", + "azure.mgmt.apimanagement.models.BackendContract": "Microsoft.ApiManagement.BackendContract", + "azure.mgmt.apimanagement.models.BackendContractProperties": "Microsoft.ApiManagement.BackendContractProperties", + "azure.mgmt.apimanagement.models.BackendCredentialsContract": "Microsoft.ApiManagement.BackendCredentialsContract", + "azure.mgmt.apimanagement.models.BackendFailureResponse": "Microsoft.ApiManagement.BackendFailureResponse", + "azure.mgmt.apimanagement.models.BackendPoolItem": "Microsoft.ApiManagement.BackendPoolItem", + "azure.mgmt.apimanagement.models.BackendProperties": "Microsoft.ApiManagement.BackendProperties", + "azure.mgmt.apimanagement.models.BackendProxyContract": "Microsoft.ApiManagement.BackendProxyContract", + "azure.mgmt.apimanagement.models.BackendReconnectContract": "Microsoft.ApiManagement.BackendReconnectContract", + "azure.mgmt.apimanagement.models.BackendReconnectProperties": "Microsoft.ApiManagement.BackendReconnectProperties", + "azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties": "Microsoft.ApiManagement.BackendServiceFabricClusterProperties", + "azure.mgmt.apimanagement.models.BackendSessionAffinity": "Microsoft.ApiManagement.BackendSessionAffinity", + "azure.mgmt.apimanagement.models.BackendSessionId": "Microsoft.ApiManagement.BackendSessionId", + "azure.mgmt.apimanagement.models.BackendSubnetConfiguration": "Microsoft.ApiManagement.BackendSubnetConfiguration", + "azure.mgmt.apimanagement.models.BackendTlsProperties": "Microsoft.ApiManagement.BackendTlsProperties", + "azure.mgmt.apimanagement.models.BackendUpdateParameterProperties": "Microsoft.ApiManagement.BackendUpdateParameterProperties", + "azure.mgmt.apimanagement.models.BackendUpdateParameters": "Microsoft.ApiManagement.BackendUpdateParameters", + "azure.mgmt.apimanagement.models.BodyDiagnosticSettings": "Microsoft.ApiManagement.BodyDiagnosticSettings", + "azure.mgmt.apimanagement.models.CacheContract": "Microsoft.ApiManagement.CacheContract", + "azure.mgmt.apimanagement.models.CacheContractProperties": "Microsoft.ApiManagement.CacheContractProperties", + "azure.mgmt.apimanagement.models.CacheUpdateParameters": "Microsoft.ApiManagement.CacheUpdateParameters", + "azure.mgmt.apimanagement.models.CacheUpdateProperties": "Microsoft.ApiManagement.CacheUpdateProperties", + "azure.mgmt.apimanagement.models.CertificateConfiguration": "Microsoft.ApiManagement.CertificateConfiguration", + "azure.mgmt.apimanagement.models.CertificateContract": "Microsoft.ApiManagement.CertificateContract", + "azure.mgmt.apimanagement.models.CertificateContractProperties": "Microsoft.ApiManagement.CertificateContractProperties", + "azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters": "Microsoft.ApiManagement.CertificateCreateOrUpdateParameters", + "azure.mgmt.apimanagement.models.CertificateCreateOrUpdateProperties": "Microsoft.ApiManagement.CertificateCreateOrUpdateProperties", + "azure.mgmt.apimanagement.models.CertificateInformation": "Microsoft.ApiManagement.CertificateInformation", + "azure.mgmt.apimanagement.models.CircuitBreakerFailureCondition": "Microsoft.ApiManagement.CircuitBreakerFailureCondition", + "azure.mgmt.apimanagement.models.CircuitBreakerRule": "Microsoft.ApiManagement.CircuitBreakerRule", + "azure.mgmt.apimanagement.models.ClientApplicationContract": "Microsoft.ApiManagement.ClientApplicationContract", + "azure.mgmt.apimanagement.models.ClientApplicationContractProperties": "Microsoft.ApiManagement.ClientApplicationContractProperties", + "azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract": "Microsoft.ApiManagement.ClientApplicationProductLinkContract", + "azure.mgmt.apimanagement.models.ClientApplicationProductLinkContractProperties": "Microsoft.ApiManagement.ClientApplicationProductLinkContractProperties", + "azure.mgmt.apimanagement.models.ClientApplicationSecretsContract": "Microsoft.ApiManagement.ClientApplicationSecretsContract", + "azure.mgmt.apimanagement.models.ClientApplicationSecretsContractEntra": "Microsoft.ApiManagement.ClientApplicationSecretsContractEntra", + "azure.mgmt.apimanagement.models.ClientSecretContract": "Microsoft.ApiManagement.ClientSecretContract", + "azure.mgmt.apimanagement.models.ConfigurationApi": "Microsoft.ApiManagement.ConfigurationApi", + "azure.mgmt.apimanagement.models.ConnectivityCheckRequest": "Microsoft.ApiManagement.ConnectivityCheckRequest", + "azure.mgmt.apimanagement.models.ConnectivityCheckRequestDestination": "Microsoft.ApiManagement.ConnectivityCheckRequestDestination", + "azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration": "Microsoft.ApiManagement.ConnectivityCheckRequestProtocolConfiguration", + "azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration": "Microsoft.ApiManagement.ConnectivityCheckRequestProtocolConfigurationHttpConfiguration", + "azure.mgmt.apimanagement.models.ConnectivityCheckRequestSource": "Microsoft.ApiManagement.ConnectivityCheckRequestSource", + "azure.mgmt.apimanagement.models.ConnectivityCheckResponse": "Microsoft.ApiManagement.ConnectivityCheckResponse", + "azure.mgmt.apimanagement.models.ConnectivityHop": "Microsoft.ApiManagement.ConnectivityHop", + "azure.mgmt.apimanagement.models.ConnectivityIssue": "Microsoft.ApiManagement.ConnectivityIssue", + "azure.mgmt.apimanagement.models.ConnectivityStatusContract": "Microsoft.ApiManagement.ConnectivityStatusContract", + "azure.mgmt.apimanagement.models.ContentItemContract": "Microsoft.ApiManagement.ContentItemContract", + "azure.mgmt.apimanagement.models.ContentTypeContract": "Microsoft.ApiManagement.ContentTypeContract", + "azure.mgmt.apimanagement.models.ContentTypeContractProperties": "Microsoft.ApiManagement.ContentTypeContractProperties", + "azure.mgmt.apimanagement.models.DataMasking": "Microsoft.ApiManagement.DataMasking", + "azure.mgmt.apimanagement.models.DataMaskingEntity": "Microsoft.ApiManagement.DataMaskingEntity", + "azure.mgmt.apimanagement.models.DeletedServiceContract": "Microsoft.ApiManagement.DeletedServiceContract", + "azure.mgmt.apimanagement.models.DeletedServiceContractProperties": "Microsoft.ApiManagement.DeletedServiceContractProperties", + "azure.mgmt.apimanagement.models.DeployConfigurationParameterProperties": "Microsoft.ApiManagement.DeployConfigurationParameterProperties", + "azure.mgmt.apimanagement.models.DeployConfigurationParameters": "Microsoft.ApiManagement.DeployConfigurationParameters", + "azure.mgmt.apimanagement.models.DiagnosticContract": "Microsoft.ApiManagement.DiagnosticContract", + "azure.mgmt.apimanagement.models.DiagnosticContractProperties": "Microsoft.ApiManagement.DiagnosticContractProperties", + "azure.mgmt.apimanagement.models.DiagnosticContractUpdateProperties": "Microsoft.ApiManagement.DiagnosticContractUpdateProperties", + "azure.mgmt.apimanagement.models.DiagnosticUpdateContract": "Microsoft.ApiManagement.DiagnosticUpdateContract", + "azure.mgmt.apimanagement.models.DocumentationContract": "Microsoft.ApiManagement.DocumentationContract", + "azure.mgmt.apimanagement.models.DocumentationContractProperties": "Microsoft.ApiManagement.DocumentationContractProperties", + "azure.mgmt.apimanagement.models.DocumentationUpdateContract": "Microsoft.ApiManagement.DocumentationUpdateContract", + "azure.mgmt.apimanagement.models.EmailTemplateContract": "Microsoft.ApiManagement.EmailTemplateContract", + "azure.mgmt.apimanagement.models.EmailTemplateContractProperties": "Microsoft.ApiManagement.EmailTemplateContractProperties", + "azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties": "Microsoft.ApiManagement.EmailTemplateParametersContractProperties", + "azure.mgmt.apimanagement.models.EmailTemplateUpdateParameterProperties": "Microsoft.ApiManagement.EmailTemplateUpdateParameterProperties", + "azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters": "Microsoft.ApiManagement.EmailTemplateUpdateParameters", + "azure.mgmt.apimanagement.models.EndpointDependency": "Microsoft.ApiManagement.EndpointDependency", + "azure.mgmt.apimanagement.models.EndpointDetail": "Microsoft.ApiManagement.EndpointDetail", + "azure.mgmt.apimanagement.models.ErrorAdditionalInfo": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "azure.mgmt.apimanagement.models.ErrorDetail": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "azure.mgmt.apimanagement.models.ErrorFieldContract": "Microsoft.ApiManagement.ErrorFieldContract", + "azure.mgmt.apimanagement.models.ErrorResponse": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "azure.mgmt.apimanagement.models.ErrorResponseBody": "Microsoft.ApiManagement.ErrorResponseBody", + "azure.mgmt.apimanagement.models.FailureStatusCodeRange": "Microsoft.ApiManagement.FailureStatusCodeRange", + "azure.mgmt.apimanagement.models.FrontendConfiguration": "Microsoft.ApiManagement.FrontendConfiguration", + "azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract": "Microsoft.ApiManagement.GatewayCertificateAuthorityContract", + "azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContractProperties": "Microsoft.ApiManagement.GatewayCertificateAuthorityContractProperties", + "azure.mgmt.apimanagement.models.GatewayConfigConnectionBaseProperties": "Microsoft.ApiManagement.GatewayConfigConnectionBaseProperties", + "azure.mgmt.apimanagement.models.GatewayConfigurationApi": "Microsoft.ApiManagement.GatewayConfigurationApi", + "azure.mgmt.apimanagement.models.GatewayContract": "Microsoft.ApiManagement.GatewayContract", + "azure.mgmt.apimanagement.models.GatewayContractProperties": "Microsoft.ApiManagement.GatewayContractProperties", + "azure.mgmt.apimanagement.models.GatewayDebugCredentialsContract": "Microsoft.ApiManagement.GatewayDebugCredentialsContract", + "azure.mgmt.apimanagement.models.GatewayHostnameBindingBaseProperties": "Microsoft.ApiManagement.GatewayHostnameBindingBaseProperties", + "azure.mgmt.apimanagement.models.GatewayHostnameBindingCertificate": "Microsoft.ApiManagement.GatewayHostnameBindingCertificate", + "azure.mgmt.apimanagement.models.GatewayHostnameBindingKeyVault": "Microsoft.ApiManagement.GatewayHostnameBindingKeyVault", + "azure.mgmt.apimanagement.models.GatewayHostnameBindingKeyVaultLastStatus": "Microsoft.ApiManagement.GatewayHostnameBindingKeyVaultLastStatus", + "azure.mgmt.apimanagement.models.GatewayHostnameBindingResource": "Microsoft.ApiManagement.GatewayHostnameBindingResource", + "azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract": "Microsoft.ApiManagement.GatewayHostnameConfigurationContract", + "azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContractProperties": "Microsoft.ApiManagement.GatewayHostnameConfigurationContractProperties", + "azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract": "Microsoft.ApiManagement.GatewayKeyRegenerationRequestContract", + "azure.mgmt.apimanagement.models.GatewayKeysContract": "Microsoft.ApiManagement.GatewayKeysContract", + "azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContract": "Microsoft.ApiManagement.GatewayListDebugCredentialsContract", + "azure.mgmt.apimanagement.models.GatewayListTraceContract": "Microsoft.ApiManagement.GatewayListTraceContract", + "azure.mgmt.apimanagement.models.GatewayResourceSkuResult": "Microsoft.ApiManagement.GatewayResourceSkuResult", + "azure.mgmt.apimanagement.models.GatewaySku": "Microsoft.ApiManagement.GatewaySku", + "azure.mgmt.apimanagement.models.GatewaySkuCapacity": "Microsoft.ApiManagement.GatewaySkuCapacity", + "azure.mgmt.apimanagement.models.GatewayTokenContract": "Microsoft.ApiManagement.GatewayTokenContract", + "azure.mgmt.apimanagement.models.GatewayTokenRequestContract": "Microsoft.ApiManagement.GatewayTokenRequestContract", + "azure.mgmt.apimanagement.models.GenerateSsoUrlResult": "Microsoft.ApiManagement.GenerateSsoUrlResult", + "azure.mgmt.apimanagement.models.GlobalSchemaContract": "Microsoft.ApiManagement.GlobalSchemaContract", + "azure.mgmt.apimanagement.models.GlobalSchemaContractProperties": "Microsoft.ApiManagement.GlobalSchemaContractProperties", + "azure.mgmt.apimanagement.models.GroupContract": "Microsoft.ApiManagement.GroupContract", + "azure.mgmt.apimanagement.models.GroupContractProperties": "Microsoft.ApiManagement.GroupContractProperties", + "azure.mgmt.apimanagement.models.GroupCreateParameters": "Microsoft.ApiManagement.GroupCreateParameters", + "azure.mgmt.apimanagement.models.GroupCreateParametersProperties": "Microsoft.ApiManagement.GroupCreateParametersProperties", + "azure.mgmt.apimanagement.models.GroupUpdateParameters": "Microsoft.ApiManagement.GroupUpdateParameters", + "azure.mgmt.apimanagement.models.GroupUpdateParametersProperties": "Microsoft.ApiManagement.GroupUpdateParametersProperties", + "azure.mgmt.apimanagement.models.HostnameConfiguration": "Microsoft.ApiManagement.HostnameConfiguration", + "azure.mgmt.apimanagement.models.HTTPHeader": "Microsoft.ApiManagement.HttpHeader", + "azure.mgmt.apimanagement.models.HttpMessageDiagnostic": "Microsoft.ApiManagement.HttpMessageDiagnostic", + "azure.mgmt.apimanagement.models.IdentityProviderBaseParameters": "Microsoft.ApiManagement.IdentityProviderBaseParameters", + "azure.mgmt.apimanagement.models.IdentityProviderContract": "Microsoft.ApiManagement.IdentityProviderContract", + "azure.mgmt.apimanagement.models.IdentityProviderContractProperties": "Microsoft.ApiManagement.IdentityProviderContractProperties", + "azure.mgmt.apimanagement.models.IdentityProviderCreateContract": "Microsoft.ApiManagement.IdentityProviderCreateContract", + "azure.mgmt.apimanagement.models.IdentityProviderCreateContractProperties": "Microsoft.ApiManagement.IdentityProviderCreateContractProperties", + "azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters": "Microsoft.ApiManagement.IdentityProviderUpdateParameters", + "azure.mgmt.apimanagement.models.IdentityProviderUpdateProperties": "Microsoft.ApiManagement.IdentityProviderUpdateProperties", + "azure.mgmt.apimanagement.models.IssueAttachmentContract": "Microsoft.ApiManagement.IssueAttachmentContract", + "azure.mgmt.apimanagement.models.IssueAttachmentContractProperties": "Microsoft.ApiManagement.IssueAttachmentContractProperties", + "azure.mgmt.apimanagement.models.IssueCommentContract": "Microsoft.ApiManagement.IssueCommentContract", + "azure.mgmt.apimanagement.models.IssueCommentContractProperties": "Microsoft.ApiManagement.IssueCommentContractProperties", + "azure.mgmt.apimanagement.models.IssueContract": "Microsoft.ApiManagement.IssueContract", + "azure.mgmt.apimanagement.models.IssueContractBaseProperties": "Microsoft.ApiManagement.IssueContractBaseProperties", + "azure.mgmt.apimanagement.models.IssueContractProperties": "Microsoft.ApiManagement.IssueContractProperties", + "azure.mgmt.apimanagement.models.IssueUpdateContract": "Microsoft.ApiManagement.IssueUpdateContract", + "azure.mgmt.apimanagement.models.IssueUpdateContractProperties": "Microsoft.ApiManagement.IssueUpdateContractProperties", + "azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties": "Microsoft.ApiManagement.KeyVaultContractCreateProperties", + "azure.mgmt.apimanagement.models.KeyVaultContractProperties": "Microsoft.ApiManagement.KeyVaultContractProperties", + "azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties": "Microsoft.ApiManagement.KeyVaultLastAccessStatusContractProperties", + "azure.mgmt.apimanagement.models.LLMDiagnosticSettings": "Microsoft.ApiManagement.LLMDiagnosticSettings", + "azure.mgmt.apimanagement.models.LLMMessageDiagnosticSettings": "Microsoft.ApiManagement.LLMMessageDiagnosticSettings", + "azure.mgmt.apimanagement.models.LoggerContract": "Microsoft.ApiManagement.LoggerContract", + "azure.mgmt.apimanagement.models.LoggerContractProperties": "Microsoft.ApiManagement.LoggerContractProperties", + "azure.mgmt.apimanagement.models.LoggerUpdateContract": "Microsoft.ApiManagement.LoggerUpdateContract", + "azure.mgmt.apimanagement.models.LoggerUpdateParameters": "Microsoft.ApiManagement.LoggerUpdateParameters", + "azure.mgmt.apimanagement.models.ManagedServiceIdentity": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentity", + "azure.mgmt.apimanagement.models.MigrateToStv2Contract": "Microsoft.ApiManagement.MigrateToStv2Contract", + "azure.mgmt.apimanagement.models.NamedValueContract": "Microsoft.ApiManagement.NamedValueContract", + "azure.mgmt.apimanagement.models.NamedValueEntityBaseParameters": "Microsoft.ApiManagement.NamedValueEntityBaseParameters", + "azure.mgmt.apimanagement.models.NamedValueContractProperties": "Microsoft.ApiManagement.NamedValueContractProperties", + "azure.mgmt.apimanagement.models.NamedValueCreateContract": "Microsoft.ApiManagement.NamedValueCreateContract", + "azure.mgmt.apimanagement.models.NamedValueCreateContractProperties": "Microsoft.ApiManagement.NamedValueCreateContractProperties", + "azure.mgmt.apimanagement.models.NamedValueSecretContract": "Microsoft.ApiManagement.NamedValueSecretContract", + "azure.mgmt.apimanagement.models.NamedValueUpdateParameterProperties": "Microsoft.ApiManagement.NamedValueUpdateParameterProperties", + "azure.mgmt.apimanagement.models.NamedValueUpdateParameters": "Microsoft.ApiManagement.NamedValueUpdateParameters", + "azure.mgmt.apimanagement.models.NetworkStatusContract": "Microsoft.ApiManagement.NetworkStatusContract", + "azure.mgmt.apimanagement.models.NetworkStatusContractByLocation": "Microsoft.ApiManagement.NetworkStatusContractByLocation", + "azure.mgmt.apimanagement.models.NotificationContract": "Microsoft.ApiManagement.NotificationContract", + "azure.mgmt.apimanagement.models.NotificationContractProperties": "Microsoft.ApiManagement.NotificationContractProperties", + "azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract": "Microsoft.ApiManagement.OAuth2AuthenticationSettingsContract", + "azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract": "Microsoft.ApiManagement.OpenIdAuthenticationSettingsContract", + "azure.mgmt.apimanagement.models.OpenidConnectProviderContract": "Microsoft.ApiManagement.OpenidConnectProviderContract", + "azure.mgmt.apimanagement.models.OpenidConnectProviderContractProperties": "Microsoft.ApiManagement.OpenidConnectProviderContractProperties", + "azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract": "Microsoft.ApiManagement.OpenidConnectProviderUpdateContract", + "azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContractProperties": "Microsoft.ApiManagement.OpenidConnectProviderUpdateContractProperties", + "azure.mgmt.apimanagement.models.Operation": "Microsoft.ApiManagement.Operation", + "azure.mgmt.apimanagement.models.OperationContract": "Microsoft.ApiManagement.OperationContract", + "azure.mgmt.apimanagement.models.OperationEntityBaseContract": "Microsoft.ApiManagement.OperationEntityBaseContract", + "azure.mgmt.apimanagement.models.OperationContractProperties": "Microsoft.ApiManagement.OperationContractProperties", + "azure.mgmt.apimanagement.models.OperationDisplay": "Microsoft.ApiManagement.OperationDisplay", + "azure.mgmt.apimanagement.models.OperationResultContract": "Microsoft.ApiManagement.OperationResultContract", + "azure.mgmt.apimanagement.models.OperationResultContractProperties": "Microsoft.ApiManagement.OperationResultContractProperties", + "azure.mgmt.apimanagement.models.OperationResultLogItemContract": "Microsoft.ApiManagement.OperationResultLogItemContract", + "azure.mgmt.apimanagement.models.OperationStatusResult": "Azure.ResourceManager.CommonTypes.OperationStatusResult", + "azure.mgmt.apimanagement.models.OperationTagResourceContractProperties": "Microsoft.ApiManagement.OperationTagResourceContractProperties", + "azure.mgmt.apimanagement.models.OperationUpdateContract": "Microsoft.ApiManagement.OperationUpdateContract", + "azure.mgmt.apimanagement.models.OperationUpdateContractProperties": "Microsoft.ApiManagement.OperationUpdateContractProperties", + "azure.mgmt.apimanagement.models.OutboundEnvironmentEndpoint": "Microsoft.ApiManagement.OutboundEnvironmentEndpoint", + "azure.mgmt.apimanagement.models.OutboundEnvironmentEndpointList": "Microsoft.ApiManagement.OutboundEnvironmentEndpointList", + "azure.mgmt.apimanagement.models.ParameterContract": "Microsoft.ApiManagement.ParameterContract", + "azure.mgmt.apimanagement.models.ParameterExampleContract": "Microsoft.ApiManagement.ParameterExampleContract", + "azure.mgmt.apimanagement.models.PipelineDiagnosticSettings": "Microsoft.ApiManagement.PipelineDiagnosticSettings", + "azure.mgmt.apimanagement.models.PolicyCollection": "Microsoft.ApiManagement.PolicyCollection", + "azure.mgmt.apimanagement.models.PolicyContract": "Microsoft.ApiManagement.PolicyContract", + "azure.mgmt.apimanagement.models.PolicyContractProperties": "Microsoft.ApiManagement.PolicyContractProperties", + "azure.mgmt.apimanagement.models.PolicyDescriptionCollection": "Microsoft.ApiManagement.PolicyDescriptionCollection", + "azure.mgmt.apimanagement.models.PolicyDescriptionContract": "Microsoft.ApiManagement.PolicyDescriptionContract", + "azure.mgmt.apimanagement.models.PolicyDescriptionContractProperties": "Microsoft.ApiManagement.PolicyDescriptionContractProperties", + "azure.mgmt.apimanagement.models.PolicyFragmentContract": "Microsoft.ApiManagement.PolicyFragmentContract", + "azure.mgmt.apimanagement.models.PolicyFragmentContractProperties": "Microsoft.ApiManagement.PolicyFragmentContractProperties", + "azure.mgmt.apimanagement.models.PolicyRestrictionContract": "Microsoft.ApiManagement.PolicyRestrictionContract", + "azure.mgmt.apimanagement.models.PolicyRestrictionContractProperties": "Microsoft.ApiManagement.PolicyRestrictionContractProperties", + "azure.mgmt.apimanagement.models.PolicyRestrictionUpdateContract": "Microsoft.ApiManagement.PolicyRestrictionUpdateContract", + "azure.mgmt.apimanagement.models.PortalConfigContract": "Microsoft.ApiManagement.PortalConfigContract", + "azure.mgmt.apimanagement.models.PortalConfigCorsProperties": "Microsoft.ApiManagement.PortalConfigCorsProperties", + "azure.mgmt.apimanagement.models.PortalConfigCspProperties": "Microsoft.ApiManagement.PortalConfigCspProperties", + "azure.mgmt.apimanagement.models.PortalConfigDelegationProperties": "Microsoft.ApiManagement.PortalConfigDelegationProperties", + "azure.mgmt.apimanagement.models.PortalConfigProperties": "Microsoft.ApiManagement.PortalConfigProperties", + "azure.mgmt.apimanagement.models.PortalConfigPropertiesSignin": "Microsoft.ApiManagement.PortalConfigPropertiesSignin", + "azure.mgmt.apimanagement.models.PortalConfigPropertiesSignup": "Microsoft.ApiManagement.PortalConfigPropertiesSignup", + "azure.mgmt.apimanagement.models.PortalConfigTermsOfServiceProperties": "Microsoft.ApiManagement.PortalConfigTermsOfServiceProperties", + "azure.mgmt.apimanagement.models.PortalDelegationSettings": "Microsoft.ApiManagement.PortalDelegationSettings", + "azure.mgmt.apimanagement.models.PortalDelegationSettingsProperties": "Microsoft.ApiManagement.PortalDelegationSettingsProperties", + "azure.mgmt.apimanagement.models.PortalRevisionContract": "Microsoft.ApiManagement.PortalRevisionContract", + "azure.mgmt.apimanagement.models.PortalRevisionContractProperties": "Microsoft.ApiManagement.PortalRevisionContractProperties", + "azure.mgmt.apimanagement.models.PortalSettingsCollection": "Microsoft.ApiManagement.PortalSettingsCollection", + "azure.mgmt.apimanagement.models.PortalSettingsContract": "Microsoft.ApiManagement.PortalSettingsContract", + "azure.mgmt.apimanagement.models.PortalSettingsContractProperties": "Microsoft.ApiManagement.PortalSettingsContractProperties", + "azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract": "Microsoft.ApiManagement.PortalSettingValidationKeyContract", + "azure.mgmt.apimanagement.models.PortalSigninSettingProperties": "Microsoft.ApiManagement.PortalSigninSettingProperties", + "azure.mgmt.apimanagement.models.PortalSigninSettings": "Microsoft.ApiManagement.PortalSigninSettings", + "azure.mgmt.apimanagement.models.PortalSignupSettings": "Microsoft.ApiManagement.PortalSignupSettings", + "azure.mgmt.apimanagement.models.PortalSignupSettingsProperties": "Microsoft.ApiManagement.PortalSignupSettingsProperties", + "azure.mgmt.apimanagement.models.PrivateEndpoint": "Azure.ResourceManager.CommonTypes.PrivateEndpoint", + "azure.mgmt.apimanagement.models.PrivateEndpointConnection": "Microsoft.ApiManagement.PrivateEndpointConnection", + "azure.mgmt.apimanagement.models.PrivateEndpointConnectionProperties": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProperties", + "azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest": "Microsoft.ApiManagement.PrivateEndpointConnectionRequest", + "azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties": "Microsoft.ApiManagement.PrivateEndpointConnectionRequestProperties", + "azure.mgmt.apimanagement.models.PrivateEndpointConnectionWrapperProperties": "Microsoft.ApiManagement.PrivateEndpointConnectionWrapperProperties", + "azure.mgmt.apimanagement.models.PrivateLinkResource": "Microsoft.ApiManagement.PrivateLinkResource", + "azure.mgmt.apimanagement.models.PrivateLinkResourceListResult": "Azure.ResourceManager.ResourceListResult", + "azure.mgmt.apimanagement.models.PrivateLinkResourceProperties": "Azure.ResourceManager.CommonTypes.PrivateLinkResourceProperties", + "azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState": "Azure.ResourceManager.CommonTypes.PrivateLinkServiceConnectionState", + "azure.mgmt.apimanagement.models.ProductApiLinkContract": "Microsoft.ApiManagement.ProductApiLinkContract", + "azure.mgmt.apimanagement.models.ProductApiLinkContractProperties": "Microsoft.ApiManagement.ProductApiLinkContractProperties", + "azure.mgmt.apimanagement.models.ProductApplicationContract": "Microsoft.ApiManagement.ProductApplicationContract", + "azure.mgmt.apimanagement.models.ProductApplicationContractEntra": "Microsoft.ApiManagement.ProductApplicationContractEntra", + "azure.mgmt.apimanagement.models.ProductContract": "Microsoft.ApiManagement.ProductContract", + "azure.mgmt.apimanagement.models.ProductEntityBaseParameters": "Microsoft.ApiManagement.ProductEntityBaseParameters", + "azure.mgmt.apimanagement.models.ProductContractProperties": "Microsoft.ApiManagement.ProductContractProperties", + "azure.mgmt.apimanagement.models.ProductEntityBaseParametersApplication": "Microsoft.ApiManagement.ProductEntityBaseParametersApplication", + "azure.mgmt.apimanagement.models.ProductGroupLinkContract": "Microsoft.ApiManagement.ProductGroupLinkContract", + "azure.mgmt.apimanagement.models.ProductGroupLinkContractProperties": "Microsoft.ApiManagement.ProductGroupLinkContractProperties", + "azure.mgmt.apimanagement.models.ProductTagResourceContractProperties": "Microsoft.ApiManagement.ProductTagResourceContractProperties", + "azure.mgmt.apimanagement.models.ProductUpdateParameters": "Microsoft.ApiManagement.ProductUpdateParameters", + "azure.mgmt.apimanagement.models.ProductUpdateProperties": "Microsoft.ApiManagement.ProductUpdateProperties", + "azure.mgmt.apimanagement.models.QuotaCounterCollection": "Microsoft.ApiManagement.QuotaCounterCollection", + "azure.mgmt.apimanagement.models.QuotaCounterContract": "Microsoft.ApiManagement.QuotaCounterContract", + "azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties": "Microsoft.ApiManagement.QuotaCounterValueContractProperties", + "azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract": "Microsoft.ApiManagement.QuotaCounterValueUpdateContract", + "azure.mgmt.apimanagement.models.RecipientEmailCollection": "Microsoft.ApiManagement.RecipientEmailCollection", + "azure.mgmt.apimanagement.models.RecipientEmailContract": "Microsoft.ApiManagement.RecipientEmailContract", + "azure.mgmt.apimanagement.models.RecipientEmailContractProperties": "Microsoft.ApiManagement.RecipientEmailContractProperties", + "azure.mgmt.apimanagement.models.RecipientsContractProperties": "Microsoft.ApiManagement.RecipientsContractProperties", + "azure.mgmt.apimanagement.models.RecipientUserCollection": "Microsoft.ApiManagement.RecipientUserCollection", + "azure.mgmt.apimanagement.models.RecipientUserContract": "Microsoft.ApiManagement.RecipientUserContract", + "azure.mgmt.apimanagement.models.RecipientUsersContractProperties": "Microsoft.ApiManagement.RecipientUsersContractProperties", + "azure.mgmt.apimanagement.models.RegionContract": "Microsoft.ApiManagement.RegionContract", + "azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties": "Microsoft.ApiManagement.RegistrationDelegationSettingsProperties", + "azure.mgmt.apimanagement.models.RemotePrivateEndpointConnectionWrapper": "Microsoft.ApiManagement.RemotePrivateEndpointConnectionWrapper", + "azure.mgmt.apimanagement.models.ReportRecordContract": "Microsoft.ApiManagement.ReportRecordContract", + "azure.mgmt.apimanagement.models.RepresentationContract": "Microsoft.ApiManagement.RepresentationContract", + "azure.mgmt.apimanagement.models.RequestContract": "Microsoft.ApiManagement.RequestContract", + "azure.mgmt.apimanagement.models.RequestReportRecordContract": "Microsoft.ApiManagement.RequestReportRecordContract", + "azure.mgmt.apimanagement.models.ResolverContract": "Microsoft.ApiManagement.ResolverContract", + "azure.mgmt.apimanagement.models.ResolverEntityBaseContract": "Microsoft.ApiManagement.ResolverEntityBaseContract", + "azure.mgmt.apimanagement.models.ResolverUpdateContract": "Microsoft.ApiManagement.ResolverUpdateContract", + "azure.mgmt.apimanagement.models.ResolverUpdateContractProperties": "Microsoft.ApiManagement.ResolverUpdateContractProperties", + "azure.mgmt.apimanagement.models.ResourceCollection": "Microsoft.ApiManagement.ResourceCollection", + "azure.mgmt.apimanagement.models.ResourceCollectionValueItem": "Microsoft.ApiManagement.ResourceCollectionValueItem", + "azure.mgmt.apimanagement.models.ResourceLocationDataContract": "Microsoft.ApiManagement.ResourceLocationDataContract", + "azure.mgmt.apimanagement.models.ResourceSku": "Microsoft.ApiManagement.ResourceSku", + "azure.mgmt.apimanagement.models.ResourceSkuCapacity": "Microsoft.ApiManagement.ResourceSkuCapacity", + "azure.mgmt.apimanagement.models.ResourceSkuResult": "Microsoft.ApiManagement.ResourceSkuResult", + "azure.mgmt.apimanagement.models.ResponseContract": "Microsoft.ApiManagement.ResponseContract", + "azure.mgmt.apimanagement.models.SamplingSettings": "Microsoft.ApiManagement.SamplingSettings", + "azure.mgmt.apimanagement.models.SaveConfigurationParameter": "Microsoft.ApiManagement.SaveConfigurationParameter", + "azure.mgmt.apimanagement.models.SaveConfigurationParameterProperties": "Microsoft.ApiManagement.SaveConfigurationParameterProperties", + "azure.mgmt.apimanagement.models.SchemaContract": "Microsoft.ApiManagement.SchemaContract", + "azure.mgmt.apimanagement.models.SchemaContractProperties": "Microsoft.ApiManagement.SchemaContractProperties", + "azure.mgmt.apimanagement.models.SchemaDocumentProperties": "Microsoft.ApiManagement.SchemaDocumentProperties", + "azure.mgmt.apimanagement.models.SubscriptionContract": "Microsoft.ApiManagement.SubscriptionContract", + "azure.mgmt.apimanagement.models.SubscriptionContractProperties": "Microsoft.ApiManagement.SubscriptionContractProperties", + "azure.mgmt.apimanagement.models.SubscriptionCreateParameterProperties": "Microsoft.ApiManagement.SubscriptionCreateParameterProperties", + "azure.mgmt.apimanagement.models.SubscriptionCreateParameters": "Microsoft.ApiManagement.SubscriptionCreateParameters", + "azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract": "Microsoft.ApiManagement.SubscriptionKeyParameterNamesContract", + "azure.mgmt.apimanagement.models.SubscriptionKeysContract": "Microsoft.ApiManagement.SubscriptionKeysContract", + "azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties": "Microsoft.ApiManagement.SubscriptionsDelegationSettingsProperties", + "azure.mgmt.apimanagement.models.SubscriptionUpdateParameterProperties": "Microsoft.ApiManagement.SubscriptionUpdateParameterProperties", + "azure.mgmt.apimanagement.models.SubscriptionUpdateParameters": "Microsoft.ApiManagement.SubscriptionUpdateParameters", + "azure.mgmt.apimanagement.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.apimanagement.models.TagApiLinkContract": "Microsoft.ApiManagement.TagApiLinkContract", + "azure.mgmt.apimanagement.models.TagApiLinkContractProperties": "Microsoft.ApiManagement.TagApiLinkContractProperties", + "azure.mgmt.apimanagement.models.TagContract": "Microsoft.ApiManagement.TagContract", + "azure.mgmt.apimanagement.models.TagContractProperties": "Microsoft.ApiManagement.TagContractProperties", + "azure.mgmt.apimanagement.models.TagCreateUpdateParameters": "Microsoft.ApiManagement.TagCreateUpdateParameters", + "azure.mgmt.apimanagement.models.TagDescriptionBaseProperties": "Microsoft.ApiManagement.TagDescriptionBaseProperties", + "azure.mgmt.apimanagement.models.TagDescriptionContract": "Microsoft.ApiManagement.TagDescriptionContract", + "azure.mgmt.apimanagement.models.TagDescriptionContractProperties": "Microsoft.ApiManagement.TagDescriptionContractProperties", + "azure.mgmt.apimanagement.models.TagDescriptionCreateParameters": "Microsoft.ApiManagement.TagDescriptionCreateParameters", + "azure.mgmt.apimanagement.models.TagOperationLinkContract": "Microsoft.ApiManagement.TagOperationLinkContract", + "azure.mgmt.apimanagement.models.TagOperationLinkContractProperties": "Microsoft.ApiManagement.TagOperationLinkContractProperties", + "azure.mgmt.apimanagement.models.TagProductLinkContract": "Microsoft.ApiManagement.TagProductLinkContract", + "azure.mgmt.apimanagement.models.TagProductLinkContractProperties": "Microsoft.ApiManagement.TagProductLinkContractProperties", + "azure.mgmt.apimanagement.models.TagResourceContract": "Microsoft.ApiManagement.TagResourceContract", + "azure.mgmt.apimanagement.models.TagResourceContractProperties": "Microsoft.ApiManagement.TagTagResourceContractProperties", + "azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract": "Microsoft.ApiManagement.TenantConfigurationSyncStateContract", + "azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContractProperties": "Microsoft.ApiManagement.TenantConfigurationSyncStateContractProperties", + "azure.mgmt.apimanagement.models.TenantSettingsContract": "Microsoft.ApiManagement.TenantSettingsContract", + "azure.mgmt.apimanagement.models.TenantSettingsContractProperties": "Microsoft.ApiManagement.TenantSettingsContractProperties", + "azure.mgmt.apimanagement.models.TermsOfServiceProperties": "Microsoft.ApiManagement.TermsOfServiceProperties", + "azure.mgmt.apimanagement.models.TokenBodyParameterContract": "Microsoft.ApiManagement.TokenBodyParameterContract", + "azure.mgmt.apimanagement.models.ToolContract": "Microsoft.ApiManagement.ToolContract", + "azure.mgmt.apimanagement.models.ToolContractProperties": "Microsoft.ApiManagement.ToolContractProperties", + "azure.mgmt.apimanagement.models.UserAssignedIdentity": "Azure.ResourceManager.CommonTypes.UserAssignedIdentity", + "azure.mgmt.apimanagement.models.UserContract": "Microsoft.ApiManagement.UserContract", + "azure.mgmt.apimanagement.models.UserEntityBaseParameters": "Microsoft.ApiManagement.UserEntityBaseParameters", + "azure.mgmt.apimanagement.models.UserContractProperties": "Microsoft.ApiManagement.UserContractProperties", + "azure.mgmt.apimanagement.models.UserCreateParameterProperties": "Microsoft.ApiManagement.UserCreateParameterProperties", + "azure.mgmt.apimanagement.models.UserCreateParameters": "Microsoft.ApiManagement.UserCreateParameters", + "azure.mgmt.apimanagement.models.UserIdentityContract": "Microsoft.ApiManagement.UserIdentityContract", + "azure.mgmt.apimanagement.models.UserIdentityProperties": "Microsoft.ApiManagement.UserIdentityProperties", + "azure.mgmt.apimanagement.models.UserTokenParameterProperties": "Microsoft.ApiManagement.UserTokenParameterProperties", + "azure.mgmt.apimanagement.models.UserTokenParameters": "Microsoft.ApiManagement.UserTokenParameters", + "azure.mgmt.apimanagement.models.UserTokenResult": "Microsoft.ApiManagement.UserTokenResult", + "azure.mgmt.apimanagement.models.UserUpdateParameters": "Microsoft.ApiManagement.UserUpdateParameters", + "azure.mgmt.apimanagement.models.UserUpdateParametersProperties": "Microsoft.ApiManagement.UserUpdateParametersProperties", + "azure.mgmt.apimanagement.models.VirtualNetworkConfiguration": "Microsoft.ApiManagement.VirtualNetworkConfiguration", + "azure.mgmt.apimanagement.models.WikiContract": "Microsoft.ApiManagement.WikiContract", + "azure.mgmt.apimanagement.models.WikiContractProperties": "Microsoft.ApiManagement.WikiContractProperties", + "azure.mgmt.apimanagement.models.WikiDocumentationContract": "Microsoft.ApiManagement.WikiDocumentationContract", + "azure.mgmt.apimanagement.models.WikiUpdateContract": "Microsoft.ApiManagement.WikiUpdateContract", + "azure.mgmt.apimanagement.models.WorkspaceContract": "Microsoft.ApiManagement.WorkspaceContract", + "azure.mgmt.apimanagement.models.WorkspaceContractProperties": "Microsoft.ApiManagement.WorkspaceContractProperties", + "azure.mgmt.apimanagement.models.WorkspaceLinksGateway": "Microsoft.ApiManagement.WorkspaceLinksGateway", + "azure.mgmt.apimanagement.models.X509CertificateName": "Microsoft.ApiManagement.X509CertificateName", + "azure.mgmt.apimanagement.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.apimanagement.models.BearerTokenSendingMethods": "Microsoft.ApiManagement.BearerTokenSendingMethods", + "azure.mgmt.apimanagement.models.ApiType": "Microsoft.ApiManagement.ApiType", + "azure.mgmt.apimanagement.models.Protocol": "Microsoft.ApiManagement.Protocol", + "azure.mgmt.apimanagement.models.VersioningScheme": "Microsoft.ApiManagement.VersioningScheme", + "azure.mgmt.apimanagement.models.ContentFormat": "Microsoft.ApiManagement.ContentFormat", + "azure.mgmt.apimanagement.models.SoapApiType": "Microsoft.ApiManagement.SoapApiType", + "azure.mgmt.apimanagement.models.TranslateRequiredQueryParametersConduct": "Microsoft.ApiManagement.TranslateRequiredQueryParametersConduct", + "azure.mgmt.apimanagement.models.PolicyContentFormat": "Microsoft.ApiManagement.PolicyContentFormat", + "azure.mgmt.apimanagement.models.PolicyIdName": "Microsoft.ApiManagement.PolicyIdName", + "azure.mgmt.apimanagement.models.PolicyExportFormat": "Microsoft.ApiManagement.PolicyExportFormat", + "azure.mgmt.apimanagement.models.AlwaysLog": "Microsoft.ApiManagement.AlwaysLog", + "azure.mgmt.apimanagement.models.SamplingType": "Microsoft.ApiManagement.SamplingType", + "azure.mgmt.apimanagement.models.DataMaskingMode": "Microsoft.ApiManagement.DataMaskingMode", + "azure.mgmt.apimanagement.models.LlmDiagnosticSettings": "Microsoft.ApiManagement.LlmDiagnosticSettings", + "azure.mgmt.apimanagement.models.LlmMessageLogTypes": "Microsoft.ApiManagement.LlmMessageLogTypes", + "azure.mgmt.apimanagement.models.HttpCorrelationProtocol": "Microsoft.ApiManagement.HttpCorrelationProtocol", + "azure.mgmt.apimanagement.models.Verbosity": "Microsoft.ApiManagement.Verbosity", + "azure.mgmt.apimanagement.models.OperationNameFormat": "Microsoft.ApiManagement.OperationNameFormat", + "azure.mgmt.apimanagement.models.State": "Microsoft.ApiManagement.State", + "azure.mgmt.apimanagement.models.CarbonEmissionCategory": "Microsoft.ApiManagement.CarbonEmissionCategory", + "azure.mgmt.apimanagement.models.BackendSessionIdSource": "Microsoft.ApiManagement.BackendSessionIdSource", + "azure.mgmt.apimanagement.models.BackendType": "Microsoft.ApiManagement.BackendType", + "azure.mgmt.apimanagement.models.BackendProtocol": "Microsoft.ApiManagement.BackendProtocol", + "azure.mgmt.apimanagement.models.GroupType": "Microsoft.ApiManagement.GroupType", + "azure.mgmt.apimanagement.models.LoggerType": "Microsoft.ApiManagement.LoggerType", + "azure.mgmt.apimanagement.models.KeyVaultRefreshState": "Microsoft.ApiManagement.KeyVaultRefreshState", + "azure.mgmt.apimanagement.models.NotificationName": "Microsoft.ApiManagement.NotificationName", + "azure.mgmt.apimanagement.models.PolicyFragmentContentFormat": "Microsoft.ApiManagement.PolicyFragmentContentFormat", + "azure.mgmt.apimanagement.models.ProductAuthType": "Microsoft.ApiManagement.ProductAuthType", + "azure.mgmt.apimanagement.models.ProductState": "Microsoft.ApiManagement.ProductState", + "azure.mgmt.apimanagement.models.SchemaType": "Microsoft.ApiManagement.SchemaType", + "azure.mgmt.apimanagement.models.SubscriptionState": "Microsoft.ApiManagement.SubscriptionState", + "azure.mgmt.apimanagement.models.AppType": "Microsoft.ApiManagement.AppType", + "azure.mgmt.apimanagement.models.VirtualNetworkType": "Microsoft.ApiManagement.VirtualNetworkType", + "azure.mgmt.apimanagement.models.ApiGatewaySkuType": "Microsoft.ApiManagement.ApiGatewaySkuType", + "azure.mgmt.apimanagement.models.GatewaySkuCapacityScaleType": "Microsoft.ApiManagement.GatewaySkuCapacityScaleType", + "azure.mgmt.apimanagement.models.HostnameType": "Microsoft.ApiManagement.HostnameType", + "azure.mgmt.apimanagement.models.CertificateSource": "Microsoft.ApiManagement.CertificateSource", + "azure.mgmt.apimanagement.models.CertificateStatus": "Microsoft.ApiManagement.CertificateStatus", + "azure.mgmt.apimanagement.models.PublicNetworkAccess": "Microsoft.ApiManagement.PublicNetworkAccess", + "azure.mgmt.apimanagement.models.LegacyApiState": "Microsoft.ApiManagement.LegacyApiState", + "azure.mgmt.apimanagement.models.SkuType": "Microsoft.ApiManagement.SkuType", + "azure.mgmt.apimanagement.models.NatGatewayState": "Microsoft.ApiManagement.NatGatewayState", + "azure.mgmt.apimanagement.models.PlatformVersion": "Microsoft.ApiManagement.PlatformVersion", + "azure.mgmt.apimanagement.models.CertificateConfigurationStoreName": "Microsoft.ApiManagement.CertificateConfigurationStoreName", + "azure.mgmt.apimanagement.models.PrivateEndpointServiceConnectionStatus": "Azure.ResourceManager.CommonTypes.PrivateEndpointServiceConnectionStatus", + "azure.mgmt.apimanagement.models.LegacyPortalStatus": "Microsoft.ApiManagement.LegacyPortalStatus", + "azure.mgmt.apimanagement.models.DeveloperPortalStatus": "Microsoft.ApiManagement.DeveloperPortalStatus", + "azure.mgmt.apimanagement.models.ReleaseChannel": "Microsoft.ApiManagement.ReleaseChannel", + "azure.mgmt.apimanagement.models.ApimIdentityType": "Microsoft.ApiManagement.ApimIdentityType", + "azure.mgmt.apimanagement.models.AccessType": "Microsoft.ApiManagement.AccessType", + "azure.mgmt.apimanagement.models.MigrateToStv2Mode": "Microsoft.ApiManagement.MigrateToStv2Mode", + "azure.mgmt.apimanagement.models.NameAvailabilityReason": "Microsoft.ApiManagement.NameAvailabilityReason", + "azure.mgmt.apimanagement.models.PolicyComplianceState": "Microsoft.ApiManagement.PolicyComplianceState", + "azure.mgmt.apimanagement.models.ResourceSkuCapacityScaleType": "Microsoft.ApiManagement.ResourceSkuCapacityScaleType", + "azure.mgmt.apimanagement.models.ConnectivityStatusType": "Microsoft.ApiManagement.ConnectivityStatusType", + "azure.mgmt.apimanagement.models.PolicyScopeContract": "Microsoft.ApiManagement.PolicyScopeContract", + "azure.mgmt.apimanagement.models.AsyncOperationStatus": "Microsoft.ApiManagement.AsyncOperationStatus", + "azure.mgmt.apimanagement.models.AuthorizationType": "Microsoft.ApiManagement.AuthorizationType", + "azure.mgmt.apimanagement.models.OAuth2GrantType": "Microsoft.ApiManagement.OAuth2GrantType", + "azure.mgmt.apimanagement.models.AuthorizationMethod": "Microsoft.ApiManagement.AuthorizationMethod", + "azure.mgmt.apimanagement.models.ClientAuthenticationMethod": "Microsoft.ApiManagement.ClientAuthenticationMethod", + "azure.mgmt.apimanagement.models.BearerTokenSendingMethod": "Microsoft.ApiManagement.BearerTokenSendingMethod", + "azure.mgmt.apimanagement.models.GrantType": "Microsoft.ApiManagement.GrantType", + "azure.mgmt.apimanagement.models.TemplateName": "Microsoft.ApiManagement.TemplateName", + "azure.mgmt.apimanagement.models.KeyVaultFetchCode": "Microsoft.ApiManagement.KeyVaultFetchCode", + "azure.mgmt.apimanagement.models.ManagedServiceIdentityType": "Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType", + "azure.mgmt.apimanagement.models.KeyType": "Microsoft.ApiManagement.KeyType", + "azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContractPurpose": "Microsoft.ApiManagement.GatewayListDebugCredentialsContractPurpose", + "azure.mgmt.apimanagement.models.UserState": "Microsoft.ApiManagement.UserState", + "azure.mgmt.apimanagement.models.IdentityProviderType": "Microsoft.ApiManagement.IdentityProviderType", + "azure.mgmt.apimanagement.models.PolicyRestrictionRequireBase": "Microsoft.ApiManagement.PolicyRestrictionRequireBase", + "azure.mgmt.apimanagement.models.PortalSettingsCspMode": "Microsoft.ApiManagement.PortalSettingsCspMode", + "azure.mgmt.apimanagement.models.ClientApplicationState": "Microsoft.ApiManagement.ClientApplicationState", + "azure.mgmt.apimanagement.models.PortalRevisionStatus": "Microsoft.ApiManagement.PortalRevisionStatus", + "azure.mgmt.apimanagement.models.PrivateEndpointConnectionProvisioningState": "Azure.ResourceManager.CommonTypes.PrivateEndpointConnectionProvisioningState", + "azure.mgmt.apimanagement.models.SettingsTypeName": "Microsoft.ApiManagement.SettingsTypeName", + "azure.mgmt.apimanagement.models.AccessIdName": "Microsoft.ApiManagement.AccessIdName", + "azure.mgmt.apimanagement.models.ConfigurationIdName": "Microsoft.ApiManagement.ConfigurationIdName", + "azure.mgmt.apimanagement.models.Confirmation": "Microsoft.ApiManagement.Confirmation", + "azure.mgmt.apimanagement.models.ExportResultFormat": "Microsoft.ApiManagement.ExportResultFormat", + "azure.mgmt.apimanagement.models.ExportFormat": "Microsoft.ApiManagement.ExportFormat", + "azure.mgmt.apimanagement.models.ExportApi": "Microsoft.ApiManagement.ExportApi", + "azure.mgmt.apimanagement.models.ApiManagementSkuCapacityScaleType": "Microsoft.ApiManagement.ApiManagementSkuCapacityScaleType", + "azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsType": "Microsoft.ApiManagement.ApiManagementSkuRestrictionsType", + "azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsReasonCode": "Microsoft.ApiManagement.ApiManagementSkuRestrictionsReasonCode", + "azure.mgmt.apimanagement.models.Origin": "Microsoft.ApiManagement.Origin", + "azure.mgmt.apimanagement.models.Severity": "Microsoft.ApiManagement.Severity", + "azure.mgmt.apimanagement.models.IssueType": "Microsoft.ApiManagement.IssueType", + "azure.mgmt.apimanagement.models.ConnectionStatus": "Microsoft.ApiManagement.ConnectionStatus", + "azure.mgmt.apimanagement.models.PreferredIPVersion": "Microsoft.ApiManagement.PreferredIPVersion", + "azure.mgmt.apimanagement.models.ConnectivityCheckProtocol": "Microsoft.ApiManagement.ConnectivityCheckProtocol", + "azure.mgmt.apimanagement.models.Method": "Microsoft.ApiManagement.Method", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperations.get": "Microsoft.ApiManagement.WorkspaceApi.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperations.get": "Microsoft.ApiManagement.WorkspaceApi.get", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApi.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApi.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspaceApi.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspaceApi.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperations.update": "Microsoft.ApiManagement.WorkspaceApi.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperations.update": "Microsoft.ApiManagement.WorkspaceApi.update", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperations.delete": "Microsoft.ApiManagement.WorkspaceApi.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperations.delete": "Microsoft.ApiManagement.WorkspaceApi.delete", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceApi.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceApi.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceApiReleaseOperations.get": "Microsoft.ApiManagement.WorkspaceApiRelease.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiReleaseOperations.get": "Microsoft.ApiManagement.WorkspaceApiRelease.get", + "azure.mgmt.apimanagement.operations.WorkspaceApiReleaseOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiRelease.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiReleaseOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiRelease.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceApiReleaseOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiRelease.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiReleaseOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiRelease.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceApiReleaseOperations.update": "Microsoft.ApiManagement.WorkspaceApiRelease.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiReleaseOperations.update": "Microsoft.ApiManagement.WorkspaceApiRelease.update", + "azure.mgmt.apimanagement.operations.WorkspaceApiReleaseOperations.delete": "Microsoft.ApiManagement.WorkspaceApiRelease.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiReleaseOperations.delete": "Microsoft.ApiManagement.WorkspaceApiRelease.delete", + "azure.mgmt.apimanagement.operations.WorkspaceApiReleaseOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceApiRelease.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiReleaseOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceApiRelease.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationOperations.get": "Microsoft.ApiManagement.WorkspaceApiOperation.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationOperations.get": "Microsoft.ApiManagement.WorkspaceApiOperation.get", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiOperation.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiOperation.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiOperation.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiOperation.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationOperations.update": "Microsoft.ApiManagement.WorkspaceApiOperation.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationOperations.update": "Microsoft.ApiManagement.WorkspaceApiOperation.update", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationOperations.delete": "Microsoft.ApiManagement.WorkspaceApiOperation.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationOperations.delete": "Microsoft.ApiManagement.WorkspaceApiOperation.delete", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationOperations.list_by_api": "Microsoft.ApiManagement.WorkspaceApiOperation.listByApi", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationOperations.list_by_api": "Microsoft.ApiManagement.WorkspaceApiOperation.listByApi", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverPolicyOperations.get": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.get", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverPolicyOperations.get": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.get", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.getEntityTag", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverPolicyOperations.create_or_update": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverPolicyOperations.create_or_update": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.createOrUpdate", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverPolicyOperations.delete": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.delete", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverPolicyOperations.delete": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.delete", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverPolicyOperations.list_by_resolver": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.listByResolver", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverPolicyOperations.list_by_resolver": "Microsoft.ApiManagement.GraphQLApiResolverPolicy.listByResolver", + "azure.mgmt.apimanagement.operations.ApiPolicyOperations.get": "Microsoft.ApiManagement.ApiPolicy.get", + "azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations.get": "Microsoft.ApiManagement.ApiPolicy.get", + "azure.mgmt.apimanagement.operations.ApiPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.ApiPolicy.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.ApiPolicy.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiPolicyOperations.create_or_update": "Microsoft.ApiManagement.ApiPolicy.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations.create_or_update": "Microsoft.ApiManagement.ApiPolicy.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiPolicyOperations.delete": "Microsoft.ApiManagement.ApiPolicy.delete", + "azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations.delete": "Microsoft.ApiManagement.ApiPolicy.delete", + "azure.mgmt.apimanagement.operations.ApiPolicyOperations.list_by_api": "Microsoft.ApiManagement.ApiPolicy.listByApi", + "azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations.list_by_api": "Microsoft.ApiManagement.ApiPolicy.listByApi", + "azure.mgmt.apimanagement.operations.PolicyOperations.get": "Microsoft.ApiManagement.Policy.get", + "azure.mgmt.apimanagement.aio.operations.PolicyOperations.get": "Microsoft.ApiManagement.Policy.get", + "azure.mgmt.apimanagement.operations.PolicyOperations.get_entity_tag": "Microsoft.ApiManagement.Policy.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.PolicyOperations.get_entity_tag": "Microsoft.ApiManagement.Policy.getEntityTag", + "azure.mgmt.apimanagement.operations.PolicyOperations.create_or_update": "Microsoft.ApiManagement.Policy.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.PolicyOperations.create_or_update": "Microsoft.ApiManagement.Policy.createOrUpdate", + "azure.mgmt.apimanagement.operations.PolicyOperations.delete": "Microsoft.ApiManagement.Policy.delete", + "azure.mgmt.apimanagement.aio.operations.PolicyOperations.delete": "Microsoft.ApiManagement.Policy.delete", + "azure.mgmt.apimanagement.operations.PolicyOperations.list_by_service": "Microsoft.ApiManagement.Policy.listByService", + "azure.mgmt.apimanagement.aio.operations.PolicyOperations.list_by_service": "Microsoft.ApiManagement.Policy.listByService", + "azure.mgmt.apimanagement.operations.ProductPolicyOperations.get": "Microsoft.ApiManagement.ProductPolicy.get", + "azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations.get": "Microsoft.ApiManagement.ProductPolicy.get", + "azure.mgmt.apimanagement.operations.ProductPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.ProductPolicy.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.ProductPolicy.getEntityTag", + "azure.mgmt.apimanagement.operations.ProductPolicyOperations.create_or_update": "Microsoft.ApiManagement.ProductPolicy.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations.create_or_update": "Microsoft.ApiManagement.ProductPolicy.createOrUpdate", + "azure.mgmt.apimanagement.operations.ProductPolicyOperations.delete": "Microsoft.ApiManagement.ProductPolicy.delete", + "azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations.delete": "Microsoft.ApiManagement.ProductPolicy.delete", + "azure.mgmt.apimanagement.operations.ProductPolicyOperations.list_by_product": "Microsoft.ApiManagement.ProductPolicy.listByProduct", + "azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations.list_by_product": "Microsoft.ApiManagement.ProductPolicy.listByProduct", + "azure.mgmt.apimanagement.operations.WorkspacePolicyOperations.get": "Microsoft.ApiManagement.WorkspacePolicy.get", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyOperations.get": "Microsoft.ApiManagement.WorkspacePolicy.get", + "azure.mgmt.apimanagement.operations.WorkspacePolicyOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspacePolicy.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspacePolicy.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspacePolicyOperations.create_or_update": "Microsoft.ApiManagement.WorkspacePolicy.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyOperations.create_or_update": "Microsoft.ApiManagement.WorkspacePolicy.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspacePolicyOperations.delete": "Microsoft.ApiManagement.WorkspacePolicy.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyOperations.delete": "Microsoft.ApiManagement.WorkspacePolicy.delete", + "azure.mgmt.apimanagement.operations.WorkspacePolicyOperations.list_by_api": "Microsoft.ApiManagement.WorkspacePolicy.listByApi", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyOperations.list_by_api": "Microsoft.ApiManagement.WorkspacePolicy.listByApi", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationPolicyOperations.get": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationPolicyOperations.get": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.get", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationPolicyOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationPolicyOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationPolicyOperations.delete": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationPolicyOperations.delete": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.delete", + "azure.mgmt.apimanagement.operations.WorkspaceApiOperationPolicyOperations.list_by_operation": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.listByOperation", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperationPolicyOperations.list_by_operation": "Microsoft.ApiManagement.WorkspaceApiOperationPolicy.listByOperation", + "azure.mgmt.apimanagement.operations.WorkspaceApiPolicyOperations.get": "Microsoft.ApiManagement.WorkspaceApiPolicy.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiPolicyOperations.get": "Microsoft.ApiManagement.WorkspaceApiPolicy.get", + "azure.mgmt.apimanagement.operations.WorkspaceApiPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiPolicy.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiPolicy.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceApiPolicyOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiPolicy.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiPolicyOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiPolicy.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceApiPolicyOperations.delete": "Microsoft.ApiManagement.WorkspaceApiPolicy.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiPolicyOperations.delete": "Microsoft.ApiManagement.WorkspaceApiPolicy.delete", + "azure.mgmt.apimanagement.operations.WorkspaceApiPolicyOperations.list_by_api": "Microsoft.ApiManagement.WorkspaceApiPolicy.listByApi", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiPolicyOperations.list_by_api": "Microsoft.ApiManagement.WorkspaceApiPolicy.listByApi", + "azure.mgmt.apimanagement.operations.WorkspaceProductPolicyOperations.get": "Microsoft.ApiManagement.WorkspaceProductPolicy.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductPolicyOperations.get": "Microsoft.ApiManagement.WorkspaceProductPolicy.get", + "azure.mgmt.apimanagement.operations.WorkspaceProductPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceProductPolicy.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceProductPolicy.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceProductPolicyOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceProductPolicy.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductPolicyOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceProductPolicy.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceProductPolicyOperations.delete": "Microsoft.ApiManagement.WorkspaceProductPolicy.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductPolicyOperations.delete": "Microsoft.ApiManagement.WorkspaceProductPolicy.delete", + "azure.mgmt.apimanagement.operations.WorkspaceProductPolicyOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceProductPolicy.listByProduct", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductPolicyOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceProductPolicy.listByProduct", + "azure.mgmt.apimanagement.operations.TagOperations.get_by_api": "Microsoft.ApiManagement.Tag.getByApi", + "azure.mgmt.apimanagement.aio.operations.TagOperations.get_by_api": "Microsoft.ApiManagement.Tag.getByApi", + "azure.mgmt.apimanagement.operations.TagOperations.get_entity_state_by_api": "Microsoft.ApiManagement.Tag.getEntityStateByApi", + "azure.mgmt.apimanagement.aio.operations.TagOperations.get_entity_state_by_api": "Microsoft.ApiManagement.Tag.getEntityStateByApi", + "azure.mgmt.apimanagement.operations.TagOperations.assign_to_api": "Microsoft.ApiManagement.Tag.assignToApi", + "azure.mgmt.apimanagement.aio.operations.TagOperations.assign_to_api": "Microsoft.ApiManagement.Tag.assignToApi", + "azure.mgmt.apimanagement.operations.TagOperations.detach_from_api": "Microsoft.ApiManagement.Tag.detachFromApi", + "azure.mgmt.apimanagement.aio.operations.TagOperations.detach_from_api": "Microsoft.ApiManagement.Tag.detachFromApi", + "azure.mgmt.apimanagement.operations.TagOperations.list_by_api": "Microsoft.ApiManagement.Tag.listByApi", + "azure.mgmt.apimanagement.aio.operations.TagOperations.list_by_api": "Microsoft.ApiManagement.Tag.listByApi", + "azure.mgmt.apimanagement.operations.TagOperations.get_by_operation": "Microsoft.ApiManagement.TagContracts.getByOperation", + "azure.mgmt.apimanagement.aio.operations.TagOperations.get_by_operation": "Microsoft.ApiManagement.TagContracts.getByOperation", + "azure.mgmt.apimanagement.operations.TagOperations.get_entity_state_by_operation": "Microsoft.ApiManagement.TagContracts.getEntityStateByOperation", + "azure.mgmt.apimanagement.aio.operations.TagOperations.get_entity_state_by_operation": "Microsoft.ApiManagement.TagContracts.getEntityStateByOperation", + "azure.mgmt.apimanagement.operations.TagOperations.assign_to_operation": "Microsoft.ApiManagement.TagContracts.assignToOperation", + "azure.mgmt.apimanagement.aio.operations.TagOperations.assign_to_operation": "Microsoft.ApiManagement.TagContracts.assignToOperation", + "azure.mgmt.apimanagement.operations.TagOperations.detach_from_operation": "Microsoft.ApiManagement.TagContracts.detachFromOperation", + "azure.mgmt.apimanagement.aio.operations.TagOperations.detach_from_operation": "Microsoft.ApiManagement.TagContracts.detachFromOperation", + "azure.mgmt.apimanagement.operations.TagOperations.list_by_operation": "Microsoft.ApiManagement.TagContracts.listByOperation", + "azure.mgmt.apimanagement.aio.operations.TagOperations.list_by_operation": "Microsoft.ApiManagement.TagContracts.listByOperation", + "azure.mgmt.apimanagement.operations.TagOperations.get_by_product": "Microsoft.ApiManagement.TagContractOperation.getByProduct", + "azure.mgmt.apimanagement.aio.operations.TagOperations.get_by_product": "Microsoft.ApiManagement.TagContractOperation.getByProduct", + "azure.mgmt.apimanagement.operations.TagOperations.get_entity_state_by_product": "Microsoft.ApiManagement.TagContractOperation.getEntityStateByProduct", + "azure.mgmt.apimanagement.aio.operations.TagOperations.get_entity_state_by_product": "Microsoft.ApiManagement.TagContractOperation.getEntityStateByProduct", + "azure.mgmt.apimanagement.operations.TagOperations.assign_to_product": "Microsoft.ApiManagement.TagContractOperation.assignToProduct", + "azure.mgmt.apimanagement.aio.operations.TagOperations.assign_to_product": "Microsoft.ApiManagement.TagContractOperation.assignToProduct", + "azure.mgmt.apimanagement.operations.TagOperations.detach_from_product": "Microsoft.ApiManagement.TagContractOperation.detachFromProduct", + "azure.mgmt.apimanagement.aio.operations.TagOperations.detach_from_product": "Microsoft.ApiManagement.TagContractOperation.detachFromProduct", + "azure.mgmt.apimanagement.operations.TagOperations.list_by_product": "Microsoft.ApiManagement.TagContractOperation.listByProduct", + "azure.mgmt.apimanagement.aio.operations.TagOperations.list_by_product": "Microsoft.ApiManagement.TagContractOperation.listByProduct", + "azure.mgmt.apimanagement.operations.TagOperations.get": "Microsoft.ApiManagement.TagContractOperationGroup.get", + "azure.mgmt.apimanagement.aio.operations.TagOperations.get": "Microsoft.ApiManagement.TagContractOperationGroup.get", + "azure.mgmt.apimanagement.operations.TagOperations.get_entity_state": "Microsoft.ApiManagement.TagContractOperationGroup.getEntityState", + "azure.mgmt.apimanagement.aio.operations.TagOperations.get_entity_state": "Microsoft.ApiManagement.TagContractOperationGroup.getEntityState", + "azure.mgmt.apimanagement.operations.TagOperations.create_or_update": "Microsoft.ApiManagement.TagContractOperationGroup.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.TagOperations.create_or_update": "Microsoft.ApiManagement.TagContractOperationGroup.createOrUpdate", + "azure.mgmt.apimanagement.operations.TagOperations.update": "Microsoft.ApiManagement.TagContractOperationGroup.update", + "azure.mgmt.apimanagement.aio.operations.TagOperations.update": "Microsoft.ApiManagement.TagContractOperationGroup.update", + "azure.mgmt.apimanagement.operations.TagOperations.delete": "Microsoft.ApiManagement.TagContractOperationGroup.delete", + "azure.mgmt.apimanagement.aio.operations.TagOperations.delete": "Microsoft.ApiManagement.TagContractOperationGroup.delete", + "azure.mgmt.apimanagement.operations.TagOperations.list_by_service": "Microsoft.ApiManagement.TagContractOperationGroup.listByService", + "azure.mgmt.apimanagement.aio.operations.TagOperations.list_by_service": "Microsoft.ApiManagement.TagContractOperationGroup.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperations.get": "Microsoft.ApiManagement.WorkspaceTag.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperations.get": "Microsoft.ApiManagement.WorkspaceTag.get", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperations.get_entity_state": "Microsoft.ApiManagement.WorkspaceTag.getEntityState", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperations.get_entity_state": "Microsoft.ApiManagement.WorkspaceTag.getEntityState", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceTag.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceTag.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperations.update": "Microsoft.ApiManagement.WorkspaceTag.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperations.update": "Microsoft.ApiManagement.WorkspaceTag.update", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperations.delete": "Microsoft.ApiManagement.WorkspaceTag.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperations.delete": "Microsoft.ApiManagement.WorkspaceTag.delete", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceTag.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceTag.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceApiSchemaOperations.get": "Microsoft.ApiManagement.WorkspaceApiSchema.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiSchemaOperations.get": "Microsoft.ApiManagement.WorkspaceApiSchema.get", + "azure.mgmt.apimanagement.operations.WorkspaceApiSchemaOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiSchema.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiSchemaOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiSchema.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceApiSchemaOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspaceApiSchema.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiSchemaOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspaceApiSchema.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceApiSchemaOperations.delete": "Microsoft.ApiManagement.WorkspaceApiSchema.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiSchemaOperations.delete": "Microsoft.ApiManagement.WorkspaceApiSchema.delete", + "azure.mgmt.apimanagement.operations.WorkspaceApiSchemaOperations.list_by_api": "Microsoft.ApiManagement.WorkspaceApiSchema.listByApi", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiSchemaOperations.list_by_api": "Microsoft.ApiManagement.WorkspaceApiSchema.listByApi", + "azure.mgmt.apimanagement.operations.DiagnosticOperations.get": "Microsoft.ApiManagement.Diagnostic.get", + "azure.mgmt.apimanagement.aio.operations.DiagnosticOperations.get": "Microsoft.ApiManagement.Diagnostic.get", + "azure.mgmt.apimanagement.operations.DiagnosticOperations.get_entity_tag": "Microsoft.ApiManagement.Diagnostic.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.DiagnosticOperations.get_entity_tag": "Microsoft.ApiManagement.Diagnostic.getEntityTag", + "azure.mgmt.apimanagement.operations.DiagnosticOperations.create_or_update": "Microsoft.ApiManagement.Diagnostic.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.DiagnosticOperations.create_or_update": "Microsoft.ApiManagement.Diagnostic.createOrUpdate", + "azure.mgmt.apimanagement.operations.DiagnosticOperations.update": "Microsoft.ApiManagement.Diagnostic.update", + "azure.mgmt.apimanagement.aio.operations.DiagnosticOperations.update": "Microsoft.ApiManagement.Diagnostic.update", + "azure.mgmt.apimanagement.operations.DiagnosticOperations.delete": "Microsoft.ApiManagement.Diagnostic.delete", + "azure.mgmt.apimanagement.aio.operations.DiagnosticOperations.delete": "Microsoft.ApiManagement.Diagnostic.delete", + "azure.mgmt.apimanagement.operations.DiagnosticOperations.list_by_service": "Microsoft.ApiManagement.Diagnostic.listByService", + "azure.mgmt.apimanagement.aio.operations.DiagnosticOperations.list_by_service": "Microsoft.ApiManagement.Diagnostic.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceDiagnosticOperations.get": "Microsoft.ApiManagement.WorkspaceDiagnostic.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceDiagnosticOperations.get": "Microsoft.ApiManagement.WorkspaceDiagnostic.get", + "azure.mgmt.apimanagement.operations.WorkspaceDiagnosticOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceDiagnostic.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceDiagnosticOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceDiagnostic.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceDiagnosticOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceDiagnostic.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceDiagnosticOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceDiagnostic.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceDiagnosticOperations.update": "Microsoft.ApiManagement.WorkspaceDiagnostic.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceDiagnosticOperations.update": "Microsoft.ApiManagement.WorkspaceDiagnostic.update", + "azure.mgmt.apimanagement.operations.WorkspaceDiagnosticOperations.delete": "Microsoft.ApiManagement.WorkspaceDiagnostic.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceDiagnosticOperations.delete": "Microsoft.ApiManagement.WorkspaceDiagnostic.delete", + "azure.mgmt.apimanagement.operations.WorkspaceDiagnosticOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceDiagnostic.listByWorkspace", + "azure.mgmt.apimanagement.aio.operations.WorkspaceDiagnosticOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceDiagnostic.listByWorkspace", + "azure.mgmt.apimanagement.operations.WorkspaceApiDiagnosticOperations.get": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiDiagnosticOperations.get": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.get", + "azure.mgmt.apimanagement.operations.WorkspaceApiDiagnosticOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiDiagnosticOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceApiDiagnosticOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiDiagnosticOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceApiDiagnosticOperations.update": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiDiagnosticOperations.update": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.update", + "azure.mgmt.apimanagement.operations.WorkspaceApiDiagnosticOperations.delete": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiDiagnosticOperations.delete": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.delete", + "azure.mgmt.apimanagement.operations.WorkspaceApiDiagnosticOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.listByWorkspace", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiDiagnosticOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceApiDiagnostic.listByWorkspace", + "azure.mgmt.apimanagement.operations.IssueOperations.get": "Microsoft.ApiManagement.Issue.get", + "azure.mgmt.apimanagement.aio.operations.IssueOperations.get": "Microsoft.ApiManagement.Issue.get", + "azure.mgmt.apimanagement.operations.IssueOperations.list_by_service": "Microsoft.ApiManagement.Issue.listByService", + "azure.mgmt.apimanagement.aio.operations.IssueOperations.list_by_service": "Microsoft.ApiManagement.Issue.listByService", + "azure.mgmt.apimanagement.operations.ProductWikiOperations.get": "Microsoft.ApiManagement.ProductWiki.get", + "azure.mgmt.apimanagement.aio.operations.ProductWikiOperations.get": "Microsoft.ApiManagement.ProductWiki.get", + "azure.mgmt.apimanagement.operations.ProductWikiOperations.get_entity_tag": "Microsoft.ApiManagement.ProductWiki.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ProductWikiOperations.get_entity_tag": "Microsoft.ApiManagement.ProductWiki.getEntityTag", + "azure.mgmt.apimanagement.operations.ProductWikiOperations.create_or_update": "Microsoft.ApiManagement.ProductWiki.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ProductWikiOperations.create_or_update": "Microsoft.ApiManagement.ProductWiki.createOrUpdate", + "azure.mgmt.apimanagement.operations.ProductWikiOperations.update": "Microsoft.ApiManagement.ProductWiki.update", + "azure.mgmt.apimanagement.aio.operations.ProductWikiOperations.update": "Microsoft.ApiManagement.ProductWiki.update", + "azure.mgmt.apimanagement.operations.ProductWikiOperations.delete": "Microsoft.ApiManagement.ProductWiki.delete", + "azure.mgmt.apimanagement.aio.operations.ProductWikiOperations.delete": "Microsoft.ApiManagement.ProductWiki.delete", + "azure.mgmt.apimanagement.operations.WorkspaceApiVersionSetOperations.get": "Microsoft.ApiManagement.WorkspaceApiVersionSet.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiVersionSetOperations.get": "Microsoft.ApiManagement.WorkspaceApiVersionSet.get", + "azure.mgmt.apimanagement.operations.WorkspaceApiVersionSetOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiVersionSet.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiVersionSetOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceApiVersionSet.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceApiVersionSetOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiVersionSet.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiVersionSetOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceApiVersionSet.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceApiVersionSetOperations.update": "Microsoft.ApiManagement.WorkspaceApiVersionSet.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiVersionSetOperations.update": "Microsoft.ApiManagement.WorkspaceApiVersionSet.update", + "azure.mgmt.apimanagement.operations.WorkspaceApiVersionSetOperations.delete": "Microsoft.ApiManagement.WorkspaceApiVersionSet.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiVersionSetOperations.delete": "Microsoft.ApiManagement.WorkspaceApiVersionSet.delete", + "azure.mgmt.apimanagement.operations.WorkspaceApiVersionSetOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceApiVersionSet.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiVersionSetOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceApiVersionSet.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceBackendOperations.get": "Microsoft.ApiManagement.WorkspaceBackend.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceBackendOperations.get": "Microsoft.ApiManagement.WorkspaceBackend.get", + "azure.mgmt.apimanagement.operations.WorkspaceBackendOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceBackend.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceBackendOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceBackend.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceBackendOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceBackend.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceBackendOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceBackend.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceBackendOperations.update": "Microsoft.ApiManagement.WorkspaceBackend.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceBackendOperations.update": "Microsoft.ApiManagement.WorkspaceBackend.update", + "azure.mgmt.apimanagement.operations.WorkspaceBackendOperations.delete": "Microsoft.ApiManagement.WorkspaceBackend.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceBackendOperations.delete": "Microsoft.ApiManagement.WorkspaceBackend.delete", + "azure.mgmt.apimanagement.operations.WorkspaceBackendOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceBackend.listByWorkspace", + "azure.mgmt.apimanagement.aio.operations.WorkspaceBackendOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceBackend.listByWorkspace", + "azure.mgmt.apimanagement.operations.WorkspaceCertificateOperations.get": "Microsoft.ApiManagement.WorkspaceCertificate.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceCertificateOperations.get": "Microsoft.ApiManagement.WorkspaceCertificate.get", + "azure.mgmt.apimanagement.operations.WorkspaceCertificateOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceCertificate.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceCertificateOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceCertificate.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceCertificateOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceCertificate.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceCertificateOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceCertificate.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceCertificateOperations.delete": "Microsoft.ApiManagement.WorkspaceCertificate.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceCertificateOperations.delete": "Microsoft.ApiManagement.WorkspaceCertificate.delete", + "azure.mgmt.apimanagement.operations.WorkspaceCertificateOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceCertificate.listByWorkspace", + "azure.mgmt.apimanagement.aio.operations.WorkspaceCertificateOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceCertificate.listByWorkspace", + "azure.mgmt.apimanagement.operations.WorkspaceCertificateOperations.refresh_secret": "Microsoft.ApiManagement.WorkspaceCertificate.refreshSecret", + "azure.mgmt.apimanagement.aio.operations.WorkspaceCertificateOperations.refresh_secret": "Microsoft.ApiManagement.WorkspaceCertificate.refreshSecret", + "azure.mgmt.apimanagement.operations.WorkspaceGroupOperations.get": "Microsoft.ApiManagement.WorkspaceGroup.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupOperations.get": "Microsoft.ApiManagement.WorkspaceGroup.get", + "azure.mgmt.apimanagement.operations.WorkspaceGroupOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceGroup.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceGroup.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceGroupOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceGroup.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceGroup.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceGroupOperations.update": "Microsoft.ApiManagement.WorkspaceGroup.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupOperations.update": "Microsoft.ApiManagement.WorkspaceGroup.update", + "azure.mgmt.apimanagement.operations.WorkspaceGroupOperations.delete": "Microsoft.ApiManagement.WorkspaceGroup.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupOperations.delete": "Microsoft.ApiManagement.WorkspaceGroup.delete", + "azure.mgmt.apimanagement.operations.WorkspaceGroupOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceGroup.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceGroup.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceLoggerOperations.get": "Microsoft.ApiManagement.WorkspaceLogger.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceLoggerOperations.get": "Microsoft.ApiManagement.WorkspaceLogger.get", + "azure.mgmt.apimanagement.operations.WorkspaceLoggerOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceLogger.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceLoggerOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceLogger.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceLoggerOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceLogger.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceLoggerOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceLogger.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceLoggerOperations.update": "Microsoft.ApiManagement.WorkspaceLogger.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceLoggerOperations.update": "Microsoft.ApiManagement.WorkspaceLogger.update", + "azure.mgmt.apimanagement.operations.WorkspaceLoggerOperations.delete": "Microsoft.ApiManagement.WorkspaceLogger.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceLoggerOperations.delete": "Microsoft.ApiManagement.WorkspaceLogger.delete", + "azure.mgmt.apimanagement.operations.WorkspaceLoggerOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceLogger.listByWorkspace", + "azure.mgmt.apimanagement.aio.operations.WorkspaceLoggerOperations.list_by_workspace": "Microsoft.ApiManagement.WorkspaceLogger.listByWorkspace", + "azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations.get": "Microsoft.ApiManagement.WorkspaceNamedValue.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations.get": "Microsoft.ApiManagement.WorkspaceNamedValue.get", + "azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceNamedValue.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceNamedValue.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspaceNamedValue.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspaceNamedValue.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations.begin_update": "Microsoft.ApiManagement.WorkspaceNamedValue.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations.begin_update": "Microsoft.ApiManagement.WorkspaceNamedValue.update", + "azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations.delete": "Microsoft.ApiManagement.WorkspaceNamedValue.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations.delete": "Microsoft.ApiManagement.WorkspaceNamedValue.delete", + "azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceNamedValue.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceNamedValue.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations.list_value": "Microsoft.ApiManagement.WorkspaceNamedValue.listValue", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations.list_value": "Microsoft.ApiManagement.WorkspaceNamedValue.listValue", + "azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations.begin_refresh_secret": "Microsoft.ApiManagement.WorkspaceNamedValue.refreshSecret", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations.begin_refresh_secret": "Microsoft.ApiManagement.WorkspaceNamedValue.refreshSecret", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationOperations.get": "Microsoft.ApiManagement.WorkspaceNotification.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationOperations.get": "Microsoft.ApiManagement.WorkspaceNotification.get", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceNotification.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceNotification.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceNotification.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceNotification.listByService", + "azure.mgmt.apimanagement.operations.WorkspacePolicyFragmentOperations.get": "Microsoft.ApiManagement.WorkspacePolicyFragment.get", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyFragmentOperations.get": "Microsoft.ApiManagement.WorkspacePolicyFragment.get", + "azure.mgmt.apimanagement.operations.WorkspacePolicyFragmentOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspacePolicyFragment.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyFragmentOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspacePolicyFragment.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspacePolicyFragmentOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspacePolicyFragment.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyFragmentOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspacePolicyFragment.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspacePolicyFragmentOperations.delete": "Microsoft.ApiManagement.WorkspacePolicyFragment.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyFragmentOperations.delete": "Microsoft.ApiManagement.WorkspacePolicyFragment.delete", + "azure.mgmt.apimanagement.operations.WorkspacePolicyFragmentOperations.list_by_service": "Microsoft.ApiManagement.WorkspacePolicyFragment.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyFragmentOperations.list_by_service": "Microsoft.ApiManagement.WorkspacePolicyFragment.listByService", + "azure.mgmt.apimanagement.operations.WorkspacePolicyFragmentOperations.list_references": "Microsoft.ApiManagement.WorkspacePolicyFragment.listReferences", + "azure.mgmt.apimanagement.aio.operations.WorkspacePolicyFragmentOperations.list_references": "Microsoft.ApiManagement.WorkspacePolicyFragment.listReferences", + "azure.mgmt.apimanagement.operations.SignInSettingsOperations.get": "Microsoft.ApiManagement.SignInSettings.get", + "azure.mgmt.apimanagement.aio.operations.SignInSettingsOperations.get": "Microsoft.ApiManagement.SignInSettings.get", + "azure.mgmt.apimanagement.operations.SignInSettingsOperations.get_entity_tag": "Microsoft.ApiManagement.SignInSettings.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.SignInSettingsOperations.get_entity_tag": "Microsoft.ApiManagement.SignInSettings.getEntityTag", + "azure.mgmt.apimanagement.operations.SignInSettingsOperations.create_or_update": "Microsoft.ApiManagement.SignInSettings.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.SignInSettingsOperations.create_or_update": "Microsoft.ApiManagement.SignInSettings.createOrUpdate", + "azure.mgmt.apimanagement.operations.SignInSettingsOperations.update": "Microsoft.ApiManagement.SignInSettings.update", + "azure.mgmt.apimanagement.aio.operations.SignInSettingsOperations.update": "Microsoft.ApiManagement.SignInSettings.update", + "azure.mgmt.apimanagement.operations.SignUpSettingsOperations.get": "Microsoft.ApiManagement.SignUpSettings.get", + "azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations.get": "Microsoft.ApiManagement.SignUpSettings.get", + "azure.mgmt.apimanagement.operations.SignUpSettingsOperations.get_entity_tag": "Microsoft.ApiManagement.SignUpSettings.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations.get_entity_tag": "Microsoft.ApiManagement.SignUpSettings.getEntityTag", + "azure.mgmt.apimanagement.operations.SignUpSettingsOperations.create_or_update": "Microsoft.ApiManagement.SignUpSettings.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations.create_or_update": "Microsoft.ApiManagement.SignUpSettings.createOrUpdate", + "azure.mgmt.apimanagement.operations.SignUpSettingsOperations.update": "Microsoft.ApiManagement.SignUpSettings.update", + "azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations.update": "Microsoft.ApiManagement.SignUpSettings.update", + "azure.mgmt.apimanagement.operations.DelegationSettingsOperations.get": "Microsoft.ApiManagement.DelegationSettings.get", + "azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations.get": "Microsoft.ApiManagement.DelegationSettings.get", + "azure.mgmt.apimanagement.operations.DelegationSettingsOperations.get_entity_tag": "Microsoft.ApiManagement.DelegationSettings.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations.get_entity_tag": "Microsoft.ApiManagement.DelegationSettings.getEntityTag", + "azure.mgmt.apimanagement.operations.DelegationSettingsOperations.create_or_update": "Microsoft.ApiManagement.DelegationSettings.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations.create_or_update": "Microsoft.ApiManagement.DelegationSettings.createOrUpdate", + "azure.mgmt.apimanagement.operations.DelegationSettingsOperations.update": "Microsoft.ApiManagement.DelegationSettings.update", + "azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations.update": "Microsoft.ApiManagement.DelegationSettings.update", + "azure.mgmt.apimanagement.operations.DelegationSettingsOperations.list_secrets": "Microsoft.ApiManagement.DelegationSettings.listSecrets", + "azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations.list_secrets": "Microsoft.ApiManagement.DelegationSettings.listSecrets", + "azure.mgmt.apimanagement.operations.WorkspaceProductOperations.get": "Microsoft.ApiManagement.WorkspaceProduct.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductOperations.get": "Microsoft.ApiManagement.WorkspaceProduct.get", + "azure.mgmt.apimanagement.operations.WorkspaceProductOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceProduct.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceProduct.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceProductOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceProduct.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceProduct.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceProductOperations.update": "Microsoft.ApiManagement.WorkspaceProduct.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductOperations.update": "Microsoft.ApiManagement.WorkspaceProduct.update", + "azure.mgmt.apimanagement.operations.WorkspaceProductOperations.delete": "Microsoft.ApiManagement.WorkspaceProduct.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductOperations.delete": "Microsoft.ApiManagement.WorkspaceProduct.delete", + "azure.mgmt.apimanagement.operations.WorkspaceProductOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceProduct.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceProduct.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceProductApiLinkOperations.get": "Microsoft.ApiManagement.WorkspaceProductApiLink.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductApiLinkOperations.get": "Microsoft.ApiManagement.WorkspaceProductApiLink.get", + "azure.mgmt.apimanagement.operations.WorkspaceProductApiLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceProductApiLink.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductApiLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceProductApiLink.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceProductApiLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceProductApiLink.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductApiLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceProductApiLink.delete", + "azure.mgmt.apimanagement.operations.WorkspaceProductApiLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceProductApiLink.listByProduct", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductApiLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceProductApiLink.listByProduct", + "azure.mgmt.apimanagement.operations.WorkspaceProductGroupLinkOperations.get": "Microsoft.ApiManagement.WorkspaceProductGroupLink.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductGroupLinkOperations.get": "Microsoft.ApiManagement.WorkspaceProductGroupLink.get", + "azure.mgmt.apimanagement.operations.WorkspaceProductGroupLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceProductGroupLink.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductGroupLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceProductGroupLink.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceProductGroupLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceProductGroupLink.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductGroupLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceProductGroupLink.delete", + "azure.mgmt.apimanagement.operations.WorkspaceProductGroupLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceProductGroupLink.listByProduct", + "azure.mgmt.apimanagement.aio.operations.WorkspaceProductGroupLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceProductGroupLink.listByProduct", + "azure.mgmt.apimanagement.operations.WorkspaceGlobalSchemaOperations.get": "Microsoft.ApiManagement.WorkspaceGlobalSchema.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGlobalSchemaOperations.get": "Microsoft.ApiManagement.WorkspaceGlobalSchema.get", + "azure.mgmt.apimanagement.operations.WorkspaceGlobalSchemaOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceGlobalSchema.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGlobalSchemaOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceGlobalSchema.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceGlobalSchemaOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspaceGlobalSchema.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGlobalSchemaOperations.begin_create_or_update": "Microsoft.ApiManagement.WorkspaceGlobalSchema.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceGlobalSchemaOperations.delete": "Microsoft.ApiManagement.WorkspaceGlobalSchema.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGlobalSchemaOperations.delete": "Microsoft.ApiManagement.WorkspaceGlobalSchema.delete", + "azure.mgmt.apimanagement.operations.WorkspaceGlobalSchemaOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceGlobalSchema.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGlobalSchemaOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceGlobalSchema.listByService", + "azure.mgmt.apimanagement.operations.UserSubscriptionOperations.get": "Microsoft.ApiManagement.UserSubscription.get", + "azure.mgmt.apimanagement.aio.operations.UserSubscriptionOperations.get": "Microsoft.ApiManagement.UserSubscription.get", + "azure.mgmt.apimanagement.operations.UserSubscriptionOperations.list": "Microsoft.ApiManagement.UserSubscription.list", + "azure.mgmt.apimanagement.aio.operations.UserSubscriptionOperations.list": "Microsoft.ApiManagement.UserSubscription.list", + "azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations.get": "Microsoft.ApiManagement.WorkspaceSubscription.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations.get": "Microsoft.ApiManagement.WorkspaceSubscription.get", + "azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceSubscription.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceSubscription.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceSubscription.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceSubscription.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations.update": "Microsoft.ApiManagement.WorkspaceSubscription.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations.update": "Microsoft.ApiManagement.WorkspaceSubscription.update", + "azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations.delete": "Microsoft.ApiManagement.WorkspaceSubscription.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations.delete": "Microsoft.ApiManagement.WorkspaceSubscription.delete", + "azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations.list": "Microsoft.ApiManagement.WorkspaceSubscription.list", + "azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations.list": "Microsoft.ApiManagement.WorkspaceSubscription.list", + "azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations.regenerate_primary_key": "Microsoft.ApiManagement.WorkspaceSubscription.regeneratePrimaryKey", + "azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations.regenerate_primary_key": "Microsoft.ApiManagement.WorkspaceSubscription.regeneratePrimaryKey", + "azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations.regenerate_secondary_key": "Microsoft.ApiManagement.WorkspaceSubscription.regenerateSecondaryKey", + "azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations.regenerate_secondary_key": "Microsoft.ApiManagement.WorkspaceSubscription.regenerateSecondaryKey", + "azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations.list_secrets": "Microsoft.ApiManagement.WorkspaceSubscription.listSecrets", + "azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations.list_secrets": "Microsoft.ApiManagement.WorkspaceSubscription.listSecrets", + "azure.mgmt.apimanagement.operations.WorkspaceTagApiLinkOperations.get": "Microsoft.ApiManagement.WorkspaceTagApiLink.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagApiLinkOperations.get": "Microsoft.ApiManagement.WorkspaceTagApiLink.get", + "azure.mgmt.apimanagement.operations.WorkspaceTagApiLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceTagApiLink.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagApiLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceTagApiLink.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceTagApiLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceTagApiLink.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagApiLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceTagApiLink.delete", + "azure.mgmt.apimanagement.operations.WorkspaceTagApiLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceTagApiLink.listByProduct", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagApiLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceTagApiLink.listByProduct", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperationLinkOperations.get": "Microsoft.ApiManagement.WorkspaceTagOperationLink.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperationLinkOperations.get": "Microsoft.ApiManagement.WorkspaceTagOperationLink.get", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperationLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceTagOperationLink.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperationLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceTagOperationLink.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperationLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceTagOperationLink.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperationLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceTagOperationLink.delete", + "azure.mgmt.apimanagement.operations.WorkspaceTagOperationLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceTagOperationLink.listByProduct", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperationLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceTagOperationLink.listByProduct", + "azure.mgmt.apimanagement.operations.WorkspaceTagProductLinkOperations.get": "Microsoft.ApiManagement.WorkspaceTagProductLink.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagProductLinkOperations.get": "Microsoft.ApiManagement.WorkspaceTagProductLink.get", + "azure.mgmt.apimanagement.operations.WorkspaceTagProductLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceTagProductLink.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagProductLinkOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceTagProductLink.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceTagProductLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceTagProductLink.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagProductLinkOperations.delete": "Microsoft.ApiManagement.WorkspaceTagProductLink.delete", + "azure.mgmt.apimanagement.operations.WorkspaceTagProductLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceTagProductLink.listByProduct", + "azure.mgmt.apimanagement.aio.operations.WorkspaceTagProductLinkOperations.list_by_product": "Microsoft.ApiManagement.WorkspaceTagProductLink.listByProduct", + "azure.mgmt.apimanagement.operations.ApiManagementOperationsOperations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.apimanagement.aio.operations.ApiManagementOperationsOperations.list": "Azure.ResourceManager.Legacy.Operations.list", + "azure.mgmt.apimanagement.operations.ApiGatewayOperations.get": "Microsoft.ApiManagement.ApiManagementGatewayResources.get", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayOperations.get": "Microsoft.ApiManagement.ApiManagementGatewayResources.get", + "azure.mgmt.apimanagement.operations.ApiGatewayOperations.begin_create_or_update": "Microsoft.ApiManagement.ApiManagementGatewayResources.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayOperations.begin_create_or_update": "Microsoft.ApiManagement.ApiManagementGatewayResources.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiGatewayOperations.begin_update": "Microsoft.ApiManagement.ApiManagementGatewayResources.update", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayOperations.begin_update": "Microsoft.ApiManagement.ApiManagementGatewayResources.update", + "azure.mgmt.apimanagement.operations.ApiGatewayOperations.begin_delete": "Microsoft.ApiManagement.ApiManagementGatewayResources.delete", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayOperations.begin_delete": "Microsoft.ApiManagement.ApiManagementGatewayResources.delete", + "azure.mgmt.apimanagement.operations.ApiGatewayOperations.list_by_resource_group": "Microsoft.ApiManagement.ApiManagementGatewayResources.listByResourceGroup", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayOperations.list_by_resource_group": "Microsoft.ApiManagement.ApiManagementGatewayResources.listByResourceGroup", + "azure.mgmt.apimanagement.operations.ApiGatewayOperations.list": "Microsoft.ApiManagement.ApiManagementGatewayResources.list", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayOperations.list": "Microsoft.ApiManagement.ApiManagementGatewayResources.list", + "azure.mgmt.apimanagement.operations.ApiManagementGatewaySkusOperations.list_available_skus": "Microsoft.ApiManagement.ApiManagementGatewayResources.listAvailableSkus", + "azure.mgmt.apimanagement.aio.operations.ApiManagementGatewaySkusOperations.list_available_skus": "Microsoft.ApiManagement.ApiManagementGatewayResources.listAvailableSkus", + "azure.mgmt.apimanagement.operations.ApiOperations.get": "Microsoft.ApiManagement.ApiContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiOperations.get": "Microsoft.ApiManagement.ApiContracts.get", + "azure.mgmt.apimanagement.operations.ApiOperations.get_entity_tag": "Microsoft.ApiManagement.ApiContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiOperations.get_entity_tag": "Microsoft.ApiManagement.ApiContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiOperations.begin_create_or_update": "Microsoft.ApiManagement.ApiContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiOperations.begin_create_or_update": "Microsoft.ApiManagement.ApiContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiOperations.update": "Microsoft.ApiManagement.ApiContracts.update", + "azure.mgmt.apimanagement.aio.operations.ApiOperations.update": "Microsoft.ApiManagement.ApiContracts.update", + "azure.mgmt.apimanagement.operations.ApiOperations.begin_delete": "Microsoft.ApiManagement.ApiContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiOperations.begin_delete": "Microsoft.ApiManagement.ApiContracts.delete", + "azure.mgmt.apimanagement.operations.ApiOperations.list_by_service": "Microsoft.ApiManagement.ApiContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ApiOperations.list_by_service": "Microsoft.ApiManagement.ApiContracts.listByService", + "azure.mgmt.apimanagement.operations.ApiOperations.list_by_tags": "Microsoft.ApiManagement.ApiManagementServiceResources.listByTags", + "azure.mgmt.apimanagement.aio.operations.ApiOperations.list_by_tags": "Microsoft.ApiManagement.ApiManagementServiceResources.listByTags", + "azure.mgmt.apimanagement.operations.ApiRevisionOperations.list_by_service": "Microsoft.ApiManagement.ApiContracts.apiRevisionListByService", + "azure.mgmt.apimanagement.aio.operations.ApiRevisionOperations.list_by_service": "Microsoft.ApiManagement.ApiContracts.apiRevisionListByService", + "azure.mgmt.apimanagement.operations.ApiProductOperations.list_by_apis": "Microsoft.ApiManagement.ApiContracts.listByApis", + "azure.mgmt.apimanagement.aio.operations.ApiProductOperations.list_by_apis": "Microsoft.ApiManagement.ApiContracts.listByApis", + "azure.mgmt.apimanagement.operations.OperationOperations.list_by_tags": "Microsoft.ApiManagement.ApiContracts.listByTags", + "azure.mgmt.apimanagement.aio.operations.OperationOperations.list_by_tags": "Microsoft.ApiManagement.ApiContracts.listByTags", + "azure.mgmt.apimanagement.operations.WorkspaceApiRevisionOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceApi.workspaceApiRevisionListByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiRevisionOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceApi.workspaceApiRevisionListByService", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.get": "Microsoft.ApiManagement.ApiManagementServiceResources.get", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.get": "Microsoft.ApiManagement.ApiManagementServiceResources.get", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.begin_create_or_update": "Microsoft.ApiManagement.ApiManagementServiceResources.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.begin_create_or_update": "Microsoft.ApiManagement.ApiManagementServiceResources.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.begin_update": "Microsoft.ApiManagement.ApiManagementServiceResources.update", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.begin_update": "Microsoft.ApiManagement.ApiManagementServiceResources.update", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.begin_delete": "Microsoft.ApiManagement.ApiManagementServiceResources.delete", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.begin_delete": "Microsoft.ApiManagement.ApiManagementServiceResources.delete", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.list_by_resource_group": "Microsoft.ApiManagement.ApiManagementServiceResources.listByResourceGroup", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.list_by_resource_group": "Microsoft.ApiManagement.ApiManagementServiceResources.listByResourceGroup", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.list": "Microsoft.ApiManagement.ApiManagementServiceResources.list", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.list": "Microsoft.ApiManagement.ApiManagementServiceResources.list", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.begin_restore": "Microsoft.ApiManagement.ApiManagementServiceResources.restore", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.begin_restore": "Microsoft.ApiManagement.ApiManagementServiceResources.restore", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.begin_backup": "Microsoft.ApiManagement.ApiManagementServiceResources.backup", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.begin_backup": "Microsoft.ApiManagement.ApiManagementServiceResources.backup", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.begin_migrate_to_stv2": "Microsoft.ApiManagement.ApiManagementServiceResources.migrateToStv2", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.begin_migrate_to_stv2": "Microsoft.ApiManagement.ApiManagementServiceResources.migrateToStv2", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.get_sso_token": "Microsoft.ApiManagement.ApiManagementServiceResources.getSsoToken", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.get_sso_token": "Microsoft.ApiManagement.ApiManagementServiceResources.getSsoToken", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.begin_apply_network_configuration_updates": "Microsoft.ApiManagement.ApiManagementServiceResources.applyNetworkConfigurationUpdates", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.begin_apply_network_configuration_updates": "Microsoft.ApiManagement.ApiManagementServiceResources.applyNetworkConfigurationUpdates", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.begin_refresh_hostnames": "Microsoft.ApiManagement.ApiManagementServiceResources.refreshHostnames", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.begin_refresh_hostnames": "Microsoft.ApiManagement.ApiManagementServiceResources.refreshHostnames", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.check_name_availability": "Microsoft.ApiManagement.ApiManagementServiceOperationGroup.checkNameAvailability", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.check_name_availability": "Microsoft.ApiManagement.ApiManagementServiceOperationGroup.checkNameAvailability", + "azure.mgmt.apimanagement.operations.ApiManagementServiceOperations.get_domain_ownership_identifier": "Microsoft.ApiManagement.ApiManagementServiceOperationGroup.getDomainOwnershipIdentifier", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations.get_domain_ownership_identifier": "Microsoft.ApiManagement.ApiManagementServiceOperationGroup.getDomainOwnershipIdentifier", + "azure.mgmt.apimanagement.operations.AllPoliciesOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.listByService", + "azure.mgmt.apimanagement.aio.operations.AllPoliciesOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.listByService", + "azure.mgmt.apimanagement.operations.ApiManagementServiceSkusOperations.list_available_service_skus": "Microsoft.ApiManagement.ApiManagementServiceResources.listAvailableServiceSkus", + "azure.mgmt.apimanagement.aio.operations.ApiManagementServiceSkusOperations.list_available_service_skus": "Microsoft.ApiManagement.ApiManagementServiceResources.listAvailableServiceSkus", + "azure.mgmt.apimanagement.operations.NetworkStatusOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.networkStatusListByService", + "azure.mgmt.apimanagement.aio.operations.NetworkStatusOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.networkStatusListByService", + "azure.mgmt.apimanagement.operations.NetworkStatusOperations.list_by_location": "Microsoft.ApiManagement.ApiManagementServiceResources.listByLocation", + "azure.mgmt.apimanagement.aio.operations.NetworkStatusOperations.list_by_location": "Microsoft.ApiManagement.ApiManagementServiceResources.listByLocation", + "azure.mgmt.apimanagement.operations.OutboundNetworkDependenciesEndpointsOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.outboundNetworkDependenciesEndpointsListByService", + "azure.mgmt.apimanagement.aio.operations.OutboundNetworkDependenciesEndpointsOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.outboundNetworkDependenciesEndpointsListByService", + "azure.mgmt.apimanagement.operations.PolicyDescriptionOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.policyDescriptionListByService", + "azure.mgmt.apimanagement.aio.operations.PolicyDescriptionOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.policyDescriptionListByService", + "azure.mgmt.apimanagement.operations.PolicyRestrictionValidationsOperations.begin_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.byService", + "azure.mgmt.apimanagement.aio.operations.PolicyRestrictionValidationsOperations.begin_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.byService", + "azure.mgmt.apimanagement.operations.PortalSettingsOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.portalSettingsListByService", + "azure.mgmt.apimanagement.aio.operations.PortalSettingsOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.portalSettingsListByService", + "azure.mgmt.apimanagement.operations.ProductOperations.list_by_tags": "Microsoft.ApiManagement.ApiManagementServiceResources.productListByTags", + "azure.mgmt.apimanagement.aio.operations.ProductOperations.list_by_tags": "Microsoft.ApiManagement.ApiManagementServiceResources.productListByTags", + "azure.mgmt.apimanagement.operations.ProductOperations.get": "Microsoft.ApiManagement.ProductContracts.get", + "azure.mgmt.apimanagement.aio.operations.ProductOperations.get": "Microsoft.ApiManagement.ProductContracts.get", + "azure.mgmt.apimanagement.operations.ProductOperations.get_entity_tag": "Microsoft.ApiManagement.ProductContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ProductOperations.get_entity_tag": "Microsoft.ApiManagement.ProductContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ProductOperations.create_or_update": "Microsoft.ApiManagement.ProductContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ProductOperations.create_or_update": "Microsoft.ApiManagement.ProductContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ProductOperations.update": "Microsoft.ApiManagement.ProductContracts.update", + "azure.mgmt.apimanagement.aio.operations.ProductOperations.update": "Microsoft.ApiManagement.ProductContracts.update", + "azure.mgmt.apimanagement.operations.ProductOperations.delete": "Microsoft.ApiManagement.ProductContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ProductOperations.delete": "Microsoft.ApiManagement.ProductContracts.delete", + "azure.mgmt.apimanagement.operations.ProductOperations.list_by_service": "Microsoft.ApiManagement.ProductContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ProductOperations.list_by_service": "Microsoft.ApiManagement.ProductContracts.listByService", + "azure.mgmt.apimanagement.operations.QuotaByCounterKeysOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.quotaByCounterKeysListByService", + "azure.mgmt.apimanagement.aio.operations.QuotaByCounterKeysOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.quotaByCounterKeysListByService", + "azure.mgmt.apimanagement.operations.QuotaByCounterKeysOperations.update": "Microsoft.ApiManagement.ApiManagementServiceResources.quotaByCounterKeysUpdate", + "azure.mgmt.apimanagement.aio.operations.QuotaByCounterKeysOperations.update": "Microsoft.ApiManagement.ApiManagementServiceResources.quotaByCounterKeysUpdate", + "azure.mgmt.apimanagement.operations.QuotaByPeriodKeysOperations.get": "Microsoft.ApiManagement.ApiManagementServiceResources.quotaByPeriodKeysGet", + "azure.mgmt.apimanagement.aio.operations.QuotaByPeriodKeysOperations.get": "Microsoft.ApiManagement.ApiManagementServiceResources.quotaByPeriodKeysGet", + "azure.mgmt.apimanagement.operations.QuotaByPeriodKeysOperations.update": "Microsoft.ApiManagement.ApiManagementServiceResources.quotaByPeriodKeysUpdate", + "azure.mgmt.apimanagement.aio.operations.QuotaByPeriodKeysOperations.update": "Microsoft.ApiManagement.ApiManagementServiceResources.quotaByPeriodKeysUpdate", + "azure.mgmt.apimanagement.operations.RegionOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.regionListByService", + "azure.mgmt.apimanagement.aio.operations.RegionOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.regionListByService", + "azure.mgmt.apimanagement.operations.ReportsOperations.list_by_api": "Microsoft.ApiManagement.ApiManagementServiceResources.listByApi", + "azure.mgmt.apimanagement.aio.operations.ReportsOperations.list_by_api": "Microsoft.ApiManagement.ApiManagementServiceResources.listByApi", + "azure.mgmt.apimanagement.operations.ReportsOperations.list_by_user": "Microsoft.ApiManagement.ApiManagementServiceResources.listByUser", + "azure.mgmt.apimanagement.aio.operations.ReportsOperations.list_by_user": "Microsoft.ApiManagement.ApiManagementServiceResources.listByUser", + "azure.mgmt.apimanagement.operations.ReportsOperations.list_by_operation": "Microsoft.ApiManagement.ApiManagementServiceResources.listByOperation", + "azure.mgmt.apimanagement.aio.operations.ReportsOperations.list_by_operation": "Microsoft.ApiManagement.ApiManagementServiceResources.listByOperation", + "azure.mgmt.apimanagement.operations.ReportsOperations.list_by_product": "Microsoft.ApiManagement.ApiManagementServiceResources.listByProduct", + "azure.mgmt.apimanagement.aio.operations.ReportsOperations.list_by_product": "Microsoft.ApiManagement.ApiManagementServiceResources.listByProduct", + "azure.mgmt.apimanagement.operations.ReportsOperations.list_by_geo": "Microsoft.ApiManagement.ApiManagementServiceResources.listByGeo", + "azure.mgmt.apimanagement.aio.operations.ReportsOperations.list_by_geo": "Microsoft.ApiManagement.ApiManagementServiceResources.listByGeo", + "azure.mgmt.apimanagement.operations.ReportsOperations.list_by_subscription": "Microsoft.ApiManagement.ApiManagementServiceResources.listBySubscription", + "azure.mgmt.apimanagement.aio.operations.ReportsOperations.list_by_subscription": "Microsoft.ApiManagement.ApiManagementServiceResources.listBySubscription", + "azure.mgmt.apimanagement.operations.ReportsOperations.list_by_time": "Microsoft.ApiManagement.ApiManagementServiceResources.listByTime", + "azure.mgmt.apimanagement.aio.operations.ReportsOperations.list_by_time": "Microsoft.ApiManagement.ApiManagementServiceResources.listByTime", + "azure.mgmt.apimanagement.operations.ReportsOperations.list_by_request": "Microsoft.ApiManagement.ApiManagementServiceResources.listByRequest", + "azure.mgmt.apimanagement.aio.operations.ReportsOperations.list_by_request": "Microsoft.ApiManagement.ApiManagementServiceResources.listByRequest", + "azure.mgmt.apimanagement.operations.TagResourceOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.tagResourceListByService", + "azure.mgmt.apimanagement.aio.operations.TagResourceOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementServiceResources.tagResourceListByService", + "azure.mgmt.apimanagement.operations.ApiReleaseOperations.get": "Microsoft.ApiManagement.ApiReleaseContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations.get": "Microsoft.ApiManagement.ApiReleaseContracts.get", + "azure.mgmt.apimanagement.operations.ApiReleaseOperations.get_entity_tag": "Microsoft.ApiManagement.ApiReleaseContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations.get_entity_tag": "Microsoft.ApiManagement.ApiReleaseContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiReleaseOperations.create_or_update": "Microsoft.ApiManagement.ApiReleaseContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations.create_or_update": "Microsoft.ApiManagement.ApiReleaseContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiReleaseOperations.update": "Microsoft.ApiManagement.ApiReleaseContracts.update", + "azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations.update": "Microsoft.ApiManagement.ApiReleaseContracts.update", + "azure.mgmt.apimanagement.operations.ApiReleaseOperations.delete": "Microsoft.ApiManagement.ApiReleaseContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations.delete": "Microsoft.ApiManagement.ApiReleaseContracts.delete", + "azure.mgmt.apimanagement.operations.ApiReleaseOperations.list_by_service": "Microsoft.ApiManagement.ApiReleaseContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations.list_by_service": "Microsoft.ApiManagement.ApiReleaseContracts.listByService", + "azure.mgmt.apimanagement.operations.ApiOperationOperations.get": "Microsoft.ApiManagement.OperationContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiOperationOperations.get": "Microsoft.ApiManagement.OperationContracts.get", + "azure.mgmt.apimanagement.operations.ApiOperationOperations.get_entity_tag": "Microsoft.ApiManagement.OperationContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiOperationOperations.get_entity_tag": "Microsoft.ApiManagement.OperationContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiOperationOperations.create_or_update": "Microsoft.ApiManagement.OperationContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiOperationOperations.create_or_update": "Microsoft.ApiManagement.OperationContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiOperationOperations.update": "Microsoft.ApiManagement.OperationContracts.update", + "azure.mgmt.apimanagement.aio.operations.ApiOperationOperations.update": "Microsoft.ApiManagement.OperationContracts.update", + "azure.mgmt.apimanagement.operations.ApiOperationOperations.delete": "Microsoft.ApiManagement.OperationContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiOperationOperations.delete": "Microsoft.ApiManagement.OperationContracts.delete", + "azure.mgmt.apimanagement.operations.ApiOperationOperations.list_by_api": "Microsoft.ApiManagement.OperationContracts.listByApi", + "azure.mgmt.apimanagement.aio.operations.ApiOperationOperations.list_by_api": "Microsoft.ApiManagement.OperationContracts.listByApi", + "azure.mgmt.apimanagement.operations.ApiOperationPolicyOperations.get": "Microsoft.ApiManagement.PolicyContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations.get": "Microsoft.ApiManagement.PolicyContracts.get", + "azure.mgmt.apimanagement.operations.ApiOperationPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.PolicyContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations.get_entity_tag": "Microsoft.ApiManagement.PolicyContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiOperationPolicyOperations.create_or_update": "Microsoft.ApiManagement.PolicyContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations.create_or_update": "Microsoft.ApiManagement.PolicyContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiOperationPolicyOperations.delete": "Microsoft.ApiManagement.PolicyContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations.delete": "Microsoft.ApiManagement.PolicyContracts.delete", + "azure.mgmt.apimanagement.operations.ApiOperationPolicyOperations.list_by_operation": "Microsoft.ApiManagement.PolicyContracts.listByOperation", + "azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations.list_by_operation": "Microsoft.ApiManagement.PolicyContracts.listByOperation", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverOperations.get": "Microsoft.ApiManagement.ResolverContracts.get", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverOperations.get": "Microsoft.ApiManagement.ResolverContracts.get", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverOperations.get_entity_tag": "Microsoft.ApiManagement.ResolverContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverOperations.get_entity_tag": "Microsoft.ApiManagement.ResolverContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverOperations.create_or_update": "Microsoft.ApiManagement.ResolverContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverOperations.create_or_update": "Microsoft.ApiManagement.ResolverContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverOperations.update": "Microsoft.ApiManagement.ResolverContracts.update", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverOperations.update": "Microsoft.ApiManagement.ResolverContracts.update", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverOperations.delete": "Microsoft.ApiManagement.ResolverContracts.delete", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverOperations.delete": "Microsoft.ApiManagement.ResolverContracts.delete", + "azure.mgmt.apimanagement.operations.GraphQLApiResolverOperations.list_by_api": "Microsoft.ApiManagement.ResolverContracts.listByApi", + "azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverOperations.list_by_api": "Microsoft.ApiManagement.ResolverContracts.listByApi", + "azure.mgmt.apimanagement.operations.ApiSchemaOperations.get": "Microsoft.ApiManagement.SchemaContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiSchemaOperations.get": "Microsoft.ApiManagement.SchemaContracts.get", + "azure.mgmt.apimanagement.operations.ApiSchemaOperations.get_entity_tag": "Microsoft.ApiManagement.SchemaContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiSchemaOperations.get_entity_tag": "Microsoft.ApiManagement.SchemaContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiSchemaOperations.begin_create_or_update": "Microsoft.ApiManagement.SchemaContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiSchemaOperations.begin_create_or_update": "Microsoft.ApiManagement.SchemaContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiSchemaOperations.delete": "Microsoft.ApiManagement.SchemaContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiSchemaOperations.delete": "Microsoft.ApiManagement.SchemaContracts.delete", + "azure.mgmt.apimanagement.operations.ApiSchemaOperations.list_by_api": "Microsoft.ApiManagement.SchemaContracts.listByApi", + "azure.mgmt.apimanagement.aio.operations.ApiSchemaOperations.list_by_api": "Microsoft.ApiManagement.SchemaContracts.listByApi", + "azure.mgmt.apimanagement.operations.ApiDiagnosticOperations.get": "Microsoft.ApiManagement.DiagnosticContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiDiagnosticOperations.get": "Microsoft.ApiManagement.DiagnosticContracts.get", + "azure.mgmt.apimanagement.operations.ApiDiagnosticOperations.get_entity_tag": "Microsoft.ApiManagement.DiagnosticContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiDiagnosticOperations.get_entity_tag": "Microsoft.ApiManagement.DiagnosticContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiDiagnosticOperations.create_or_update": "Microsoft.ApiManagement.DiagnosticContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiDiagnosticOperations.create_or_update": "Microsoft.ApiManagement.DiagnosticContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiDiagnosticOperations.update": "Microsoft.ApiManagement.DiagnosticContracts.update", + "azure.mgmt.apimanagement.aio.operations.ApiDiagnosticOperations.update": "Microsoft.ApiManagement.DiagnosticContracts.update", + "azure.mgmt.apimanagement.operations.ApiDiagnosticOperations.delete": "Microsoft.ApiManagement.DiagnosticContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiDiagnosticOperations.delete": "Microsoft.ApiManagement.DiagnosticContracts.delete", + "azure.mgmt.apimanagement.operations.ApiDiagnosticOperations.list_by_service": "Microsoft.ApiManagement.DiagnosticContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ApiDiagnosticOperations.list_by_service": "Microsoft.ApiManagement.DiagnosticContracts.listByService", + "azure.mgmt.apimanagement.operations.ApiIssueOperations.get": "Microsoft.ApiManagement.IssueContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiIssueOperations.get": "Microsoft.ApiManagement.IssueContracts.get", + "azure.mgmt.apimanagement.operations.ApiIssueOperations.get_entity_tag": "Microsoft.ApiManagement.IssueContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiIssueOperations.get_entity_tag": "Microsoft.ApiManagement.IssueContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiIssueOperations.create_or_update": "Microsoft.ApiManagement.IssueContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiIssueOperations.create_or_update": "Microsoft.ApiManagement.IssueContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiIssueOperations.update": "Microsoft.ApiManagement.IssueContracts.update", + "azure.mgmt.apimanagement.aio.operations.ApiIssueOperations.update": "Microsoft.ApiManagement.IssueContracts.update", + "azure.mgmt.apimanagement.operations.ApiIssueOperations.delete": "Microsoft.ApiManagement.IssueContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiIssueOperations.delete": "Microsoft.ApiManagement.IssueContracts.delete", + "azure.mgmt.apimanagement.operations.ApiIssueOperations.list_by_service": "Microsoft.ApiManagement.IssueContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ApiIssueOperations.list_by_service": "Microsoft.ApiManagement.IssueContracts.listByService", + "azure.mgmt.apimanagement.operations.ApiIssueCommentOperations.get": "Microsoft.ApiManagement.IssueCommentContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiIssueCommentOperations.get": "Microsoft.ApiManagement.IssueCommentContracts.get", + "azure.mgmt.apimanagement.operations.ApiIssueCommentOperations.get_entity_tag": "Microsoft.ApiManagement.IssueCommentContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiIssueCommentOperations.get_entity_tag": "Microsoft.ApiManagement.IssueCommentContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiIssueCommentOperations.create_or_update": "Microsoft.ApiManagement.IssueCommentContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiIssueCommentOperations.create_or_update": "Microsoft.ApiManagement.IssueCommentContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiIssueCommentOperations.delete": "Microsoft.ApiManagement.IssueCommentContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiIssueCommentOperations.delete": "Microsoft.ApiManagement.IssueCommentContracts.delete", + "azure.mgmt.apimanagement.operations.ApiIssueCommentOperations.list_by_service": "Microsoft.ApiManagement.IssueCommentContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ApiIssueCommentOperations.list_by_service": "Microsoft.ApiManagement.IssueCommentContracts.listByService", + "azure.mgmt.apimanagement.operations.ApiIssueAttachmentOperations.get": "Microsoft.ApiManagement.IssueAttachmentContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations.get": "Microsoft.ApiManagement.IssueAttachmentContracts.get", + "azure.mgmt.apimanagement.operations.ApiIssueAttachmentOperations.get_entity_tag": "Microsoft.ApiManagement.IssueAttachmentContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations.get_entity_tag": "Microsoft.ApiManagement.IssueAttachmentContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiIssueAttachmentOperations.create_or_update": "Microsoft.ApiManagement.IssueAttachmentContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations.create_or_update": "Microsoft.ApiManagement.IssueAttachmentContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiIssueAttachmentOperations.delete": "Microsoft.ApiManagement.IssueAttachmentContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations.delete": "Microsoft.ApiManagement.IssueAttachmentContracts.delete", + "azure.mgmt.apimanagement.operations.ApiIssueAttachmentOperations.list_by_service": "Microsoft.ApiManagement.IssueAttachmentContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations.list_by_service": "Microsoft.ApiManagement.IssueAttachmentContracts.listByService", + "azure.mgmt.apimanagement.operations.ApiTagDescriptionOperations.get": "Microsoft.ApiManagement.TagDescriptionContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations.get": "Microsoft.ApiManagement.TagDescriptionContracts.get", + "azure.mgmt.apimanagement.operations.ApiTagDescriptionOperations.get_entity_tag": "Microsoft.ApiManagement.TagDescriptionContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations.get_entity_tag": "Microsoft.ApiManagement.TagDescriptionContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiTagDescriptionOperations.create_or_update": "Microsoft.ApiManagement.TagDescriptionContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations.create_or_update": "Microsoft.ApiManagement.TagDescriptionContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiTagDescriptionOperations.delete": "Microsoft.ApiManagement.TagDescriptionContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations.delete": "Microsoft.ApiManagement.TagDescriptionContracts.delete", + "azure.mgmt.apimanagement.operations.ApiTagDescriptionOperations.list_by_service": "Microsoft.ApiManagement.TagDescriptionContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations.list_by_service": "Microsoft.ApiManagement.TagDescriptionContracts.listByService", + "azure.mgmt.apimanagement.operations.ApiWikiOperations.get": "Microsoft.ApiManagement.WikiContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiWikiOperations.get": "Microsoft.ApiManagement.WikiContracts.get", + "azure.mgmt.apimanagement.operations.ApiWikiOperations.get_entity_tag": "Microsoft.ApiManagement.WikiContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiWikiOperations.get_entity_tag": "Microsoft.ApiManagement.WikiContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiWikiOperations.create_or_update": "Microsoft.ApiManagement.WikiContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiWikiOperations.create_or_update": "Microsoft.ApiManagement.WikiContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiWikiOperations.update": "Microsoft.ApiManagement.WikiContracts.update", + "azure.mgmt.apimanagement.aio.operations.ApiWikiOperations.update": "Microsoft.ApiManagement.WikiContracts.update", + "azure.mgmt.apimanagement.operations.ApiWikiOperations.delete": "Microsoft.ApiManagement.WikiContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiWikiOperations.delete": "Microsoft.ApiManagement.WikiContracts.delete", + "azure.mgmt.apimanagement.operations.ApiWikisOperations.list": "Microsoft.ApiManagement.WikiContracts.list", + "azure.mgmt.apimanagement.aio.operations.ApiWikisOperations.list": "Microsoft.ApiManagement.WikiContracts.list", + "azure.mgmt.apimanagement.operations.ProductWikisOperations.list": "Microsoft.ApiManagement.ProductWiki.list", + "azure.mgmt.apimanagement.aio.operations.ProductWikisOperations.list": "Microsoft.ApiManagement.ProductWiki.list", + "azure.mgmt.apimanagement.operations.ApiToolOperations.get": "Microsoft.ApiManagement.ToolContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiToolOperations.get": "Microsoft.ApiManagement.ToolContracts.get", + "azure.mgmt.apimanagement.operations.ApiToolOperations.get_entity_tag": "Microsoft.ApiManagement.ToolContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiToolOperations.get_entity_tag": "Microsoft.ApiManagement.ToolContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiToolOperations.create_or_update": "Microsoft.ApiManagement.ToolContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiToolOperations.create_or_update": "Microsoft.ApiManagement.ToolContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiToolOperations.update": "Microsoft.ApiManagement.ToolContracts.update", + "azure.mgmt.apimanagement.aio.operations.ApiToolOperations.update": "Microsoft.ApiManagement.ToolContracts.update", + "azure.mgmt.apimanagement.operations.ApiToolOperations.delete": "Microsoft.ApiManagement.ToolContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiToolOperations.delete": "Microsoft.ApiManagement.ToolContracts.delete", + "azure.mgmt.apimanagement.operations.ApiToolOperations.list_by_api": "Microsoft.ApiManagement.ToolContracts.listByApi", + "azure.mgmt.apimanagement.aio.operations.ApiToolOperations.list_by_api": "Microsoft.ApiManagement.ToolContracts.listByApi", + "azure.mgmt.apimanagement.operations.ApiVersionSetOperations.get": "Microsoft.ApiManagement.ApiVersionSetContracts.get", + "azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations.get": "Microsoft.ApiManagement.ApiVersionSetContracts.get", + "azure.mgmt.apimanagement.operations.ApiVersionSetOperations.get_entity_tag": "Microsoft.ApiManagement.ApiVersionSetContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations.get_entity_tag": "Microsoft.ApiManagement.ApiVersionSetContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ApiVersionSetOperations.create_or_update": "Microsoft.ApiManagement.ApiVersionSetContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations.create_or_update": "Microsoft.ApiManagement.ApiVersionSetContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiVersionSetOperations.update": "Microsoft.ApiManagement.ApiVersionSetContracts.update", + "azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations.update": "Microsoft.ApiManagement.ApiVersionSetContracts.update", + "azure.mgmt.apimanagement.operations.ApiVersionSetOperations.delete": "Microsoft.ApiManagement.ApiVersionSetContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations.delete": "Microsoft.ApiManagement.ApiVersionSetContracts.delete", + "azure.mgmt.apimanagement.operations.ApiVersionSetOperations.list_by_service": "Microsoft.ApiManagement.ApiVersionSetContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations.list_by_service": "Microsoft.ApiManagement.ApiVersionSetContracts.listByService", + "azure.mgmt.apimanagement.operations.AuthorizationProviderOperations.get": "Microsoft.ApiManagement.AuthorizationProviderContracts.get", + "azure.mgmt.apimanagement.aio.operations.AuthorizationProviderOperations.get": "Microsoft.ApiManagement.AuthorizationProviderContracts.get", + "azure.mgmt.apimanagement.operations.AuthorizationProviderOperations.create_or_update": "Microsoft.ApiManagement.AuthorizationProviderContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.AuthorizationProviderOperations.create_or_update": "Microsoft.ApiManagement.AuthorizationProviderContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.AuthorizationProviderOperations.delete": "Microsoft.ApiManagement.AuthorizationProviderContracts.delete", + "azure.mgmt.apimanagement.aio.operations.AuthorizationProviderOperations.delete": "Microsoft.ApiManagement.AuthorizationProviderContracts.delete", + "azure.mgmt.apimanagement.operations.AuthorizationProviderOperations.list_by_service": "Microsoft.ApiManagement.AuthorizationProviderContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.AuthorizationProviderOperations.list_by_service": "Microsoft.ApiManagement.AuthorizationProviderContracts.listByService", + "azure.mgmt.apimanagement.operations.AuthorizationProviderOperations.refresh_secret": "Microsoft.ApiManagement.AuthorizationProviderContracts.refreshSecret", + "azure.mgmt.apimanagement.aio.operations.AuthorizationProviderOperations.refresh_secret": "Microsoft.ApiManagement.AuthorizationProviderContracts.refreshSecret", + "azure.mgmt.apimanagement.operations.AuthorizationOperations.get": "Microsoft.ApiManagement.AuthorizationContracts.get", + "azure.mgmt.apimanagement.aio.operations.AuthorizationOperations.get": "Microsoft.ApiManagement.AuthorizationContracts.get", + "azure.mgmt.apimanagement.operations.AuthorizationOperations.create_or_update": "Microsoft.ApiManagement.AuthorizationContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.AuthorizationOperations.create_or_update": "Microsoft.ApiManagement.AuthorizationContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.AuthorizationOperations.delete": "Microsoft.ApiManagement.AuthorizationContracts.delete", + "azure.mgmt.apimanagement.aio.operations.AuthorizationOperations.delete": "Microsoft.ApiManagement.AuthorizationContracts.delete", + "azure.mgmt.apimanagement.operations.AuthorizationOperations.list_by_authorization_provider": "Microsoft.ApiManagement.AuthorizationContracts.listByAuthorizationProvider", + "azure.mgmt.apimanagement.aio.operations.AuthorizationOperations.list_by_authorization_provider": "Microsoft.ApiManagement.AuthorizationContracts.listByAuthorizationProvider", + "azure.mgmt.apimanagement.operations.AuthorizationOperations.confirm_consent_code": "Microsoft.ApiManagement.AuthorizationContracts.confirmConsentCode", + "azure.mgmt.apimanagement.aio.operations.AuthorizationOperations.confirm_consent_code": "Microsoft.ApiManagement.AuthorizationContracts.confirmConsentCode", + "azure.mgmt.apimanagement.operations.AuthorizationLoginLinksOperations.post": "Microsoft.ApiManagement.AuthorizationContracts.post", + "azure.mgmt.apimanagement.aio.operations.AuthorizationLoginLinksOperations.post": "Microsoft.ApiManagement.AuthorizationContracts.post", + "azure.mgmt.apimanagement.operations.AuthorizationAccessPolicyOperations.get": "Microsoft.ApiManagement.AuthorizationAccessPolicyContracts.get", + "azure.mgmt.apimanagement.aio.operations.AuthorizationAccessPolicyOperations.get": "Microsoft.ApiManagement.AuthorizationAccessPolicyContracts.get", + "azure.mgmt.apimanagement.operations.AuthorizationAccessPolicyOperations.create_or_update": "Microsoft.ApiManagement.AuthorizationAccessPolicyContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.AuthorizationAccessPolicyOperations.create_or_update": "Microsoft.ApiManagement.AuthorizationAccessPolicyContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.AuthorizationAccessPolicyOperations.delete": "Microsoft.ApiManagement.AuthorizationAccessPolicyContracts.delete", + "azure.mgmt.apimanagement.aio.operations.AuthorizationAccessPolicyOperations.delete": "Microsoft.ApiManagement.AuthorizationAccessPolicyContracts.delete", + "azure.mgmt.apimanagement.operations.AuthorizationAccessPolicyOperations.list_by_authorization": "Microsoft.ApiManagement.AuthorizationAccessPolicyContracts.listByAuthorization", + "azure.mgmt.apimanagement.aio.operations.AuthorizationAccessPolicyOperations.list_by_authorization": "Microsoft.ApiManagement.AuthorizationAccessPolicyContracts.listByAuthorization", + "azure.mgmt.apimanagement.operations.AuthorizationServerOperations.get": "Microsoft.ApiManagement.AuthorizationServerContracts.get", + "azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations.get": "Microsoft.ApiManagement.AuthorizationServerContracts.get", + "azure.mgmt.apimanagement.operations.AuthorizationServerOperations.get_entity_tag": "Microsoft.ApiManagement.AuthorizationServerContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations.get_entity_tag": "Microsoft.ApiManagement.AuthorizationServerContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.AuthorizationServerOperations.create_or_update": "Microsoft.ApiManagement.AuthorizationServerContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations.create_or_update": "Microsoft.ApiManagement.AuthorizationServerContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.AuthorizationServerOperations.update": "Microsoft.ApiManagement.AuthorizationServerContracts.update", + "azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations.update": "Microsoft.ApiManagement.AuthorizationServerContracts.update", + "azure.mgmt.apimanagement.operations.AuthorizationServerOperations.delete": "Microsoft.ApiManagement.AuthorizationServerContracts.delete", + "azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations.delete": "Microsoft.ApiManagement.AuthorizationServerContracts.delete", + "azure.mgmt.apimanagement.operations.AuthorizationServerOperations.list_by_service": "Microsoft.ApiManagement.AuthorizationServerContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations.list_by_service": "Microsoft.ApiManagement.AuthorizationServerContracts.listByService", + "azure.mgmt.apimanagement.operations.AuthorizationServerOperations.list_secrets": "Microsoft.ApiManagement.AuthorizationServerContracts.listSecrets", + "azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations.list_secrets": "Microsoft.ApiManagement.AuthorizationServerContracts.listSecrets", + "azure.mgmt.apimanagement.operations.BackendOperations.get": "Microsoft.ApiManagement.BackendContracts.get", + "azure.mgmt.apimanagement.aio.operations.BackendOperations.get": "Microsoft.ApiManagement.BackendContracts.get", + "azure.mgmt.apimanagement.operations.BackendOperations.get_entity_tag": "Microsoft.ApiManagement.BackendContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.BackendOperations.get_entity_tag": "Microsoft.ApiManagement.BackendContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.BackendOperations.create_or_update": "Microsoft.ApiManagement.BackendContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.BackendOperations.create_or_update": "Microsoft.ApiManagement.BackendContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.BackendOperations.update": "Microsoft.ApiManagement.BackendContracts.update", + "azure.mgmt.apimanagement.aio.operations.BackendOperations.update": "Microsoft.ApiManagement.BackendContracts.update", + "azure.mgmt.apimanagement.operations.BackendOperations.delete": "Microsoft.ApiManagement.BackendContracts.delete", + "azure.mgmt.apimanagement.aio.operations.BackendOperations.delete": "Microsoft.ApiManagement.BackendContracts.delete", + "azure.mgmt.apimanagement.operations.BackendOperations.list_by_service": "Microsoft.ApiManagement.BackendContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.BackendOperations.list_by_service": "Microsoft.ApiManagement.BackendContracts.listByService", + "azure.mgmt.apimanagement.operations.BackendOperations.reconnect": "Microsoft.ApiManagement.BackendContracts.reconnect", + "azure.mgmt.apimanagement.aio.operations.BackendOperations.reconnect": "Microsoft.ApiManagement.BackendContracts.reconnect", + "azure.mgmt.apimanagement.operations.CacheOperations.get": "Microsoft.ApiManagement.CacheContracts.get", + "azure.mgmt.apimanagement.aio.operations.CacheOperations.get": "Microsoft.ApiManagement.CacheContracts.get", + "azure.mgmt.apimanagement.operations.CacheOperations.get_entity_tag": "Microsoft.ApiManagement.CacheContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.CacheOperations.get_entity_tag": "Microsoft.ApiManagement.CacheContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.CacheOperations.create_or_update": "Microsoft.ApiManagement.CacheContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.CacheOperations.create_or_update": "Microsoft.ApiManagement.CacheContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.CacheOperations.update": "Microsoft.ApiManagement.CacheContracts.update", + "azure.mgmt.apimanagement.aio.operations.CacheOperations.update": "Microsoft.ApiManagement.CacheContracts.update", + "azure.mgmt.apimanagement.operations.CacheOperations.delete": "Microsoft.ApiManagement.CacheContracts.delete", + "azure.mgmt.apimanagement.aio.operations.CacheOperations.delete": "Microsoft.ApiManagement.CacheContracts.delete", + "azure.mgmt.apimanagement.operations.CacheOperations.list_by_service": "Microsoft.ApiManagement.CacheContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.CacheOperations.list_by_service": "Microsoft.ApiManagement.CacheContracts.listByService", + "azure.mgmt.apimanagement.operations.CertificateOperations.get": "Microsoft.ApiManagement.CertificateContracts.get", + "azure.mgmt.apimanagement.aio.operations.CertificateOperations.get": "Microsoft.ApiManagement.CertificateContracts.get", + "azure.mgmt.apimanagement.operations.CertificateOperations.get_entity_tag": "Microsoft.ApiManagement.CertificateContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.CertificateOperations.get_entity_tag": "Microsoft.ApiManagement.CertificateContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.CertificateOperations.create_or_update": "Microsoft.ApiManagement.CertificateContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.CertificateOperations.create_or_update": "Microsoft.ApiManagement.CertificateContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.CertificateOperations.delete": "Microsoft.ApiManagement.CertificateContracts.delete", + "azure.mgmt.apimanagement.aio.operations.CertificateOperations.delete": "Microsoft.ApiManagement.CertificateContracts.delete", + "azure.mgmt.apimanagement.operations.CertificateOperations.list_by_service": "Microsoft.ApiManagement.CertificateContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.CertificateOperations.list_by_service": "Microsoft.ApiManagement.CertificateContracts.listByService", + "azure.mgmt.apimanagement.operations.CertificateOperations.refresh_secret": "Microsoft.ApiManagement.CertificateContracts.refreshSecret", + "azure.mgmt.apimanagement.aio.operations.CertificateOperations.refresh_secret": "Microsoft.ApiManagement.CertificateContracts.refreshSecret", + "azure.mgmt.apimanagement.operations.ContentTypeOperations.get": "Microsoft.ApiManagement.ContentTypeContracts.get", + "azure.mgmt.apimanagement.aio.operations.ContentTypeOperations.get": "Microsoft.ApiManagement.ContentTypeContracts.get", + "azure.mgmt.apimanagement.operations.ContentTypeOperations.create_or_update": "Microsoft.ApiManagement.ContentTypeContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ContentTypeOperations.create_or_update": "Microsoft.ApiManagement.ContentTypeContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ContentTypeOperations.delete": "Microsoft.ApiManagement.ContentTypeContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ContentTypeOperations.delete": "Microsoft.ApiManagement.ContentTypeContracts.delete", + "azure.mgmt.apimanagement.operations.ContentTypeOperations.list_by_service": "Microsoft.ApiManagement.ContentTypeContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ContentTypeOperations.list_by_service": "Microsoft.ApiManagement.ContentTypeContracts.listByService", + "azure.mgmt.apimanagement.operations.ContentItemOperations.get": "Microsoft.ApiManagement.ContentItemContracts.get", + "azure.mgmt.apimanagement.aio.operations.ContentItemOperations.get": "Microsoft.ApiManagement.ContentItemContracts.get", + "azure.mgmt.apimanagement.operations.ContentItemOperations.get_entity_tag": "Microsoft.ApiManagement.ContentItemContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ContentItemOperations.get_entity_tag": "Microsoft.ApiManagement.ContentItemContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ContentItemOperations.create_or_update": "Microsoft.ApiManagement.ContentItemContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ContentItemOperations.create_or_update": "Microsoft.ApiManagement.ContentItemContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ContentItemOperations.delete": "Microsoft.ApiManagement.ContentItemContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ContentItemOperations.delete": "Microsoft.ApiManagement.ContentItemContracts.delete", + "azure.mgmt.apimanagement.operations.ContentItemOperations.list_by_service": "Microsoft.ApiManagement.ContentItemContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ContentItemOperations.list_by_service": "Microsoft.ApiManagement.ContentItemContracts.listByService", + "azure.mgmt.apimanagement.operations.DeletedServicesOperations.get_by_name": "Microsoft.ApiManagement.DeletedServiceContracts.getByName", + "azure.mgmt.apimanagement.aio.operations.DeletedServicesOperations.get_by_name": "Microsoft.ApiManagement.DeletedServiceContracts.getByName", + "azure.mgmt.apimanagement.operations.DeletedServicesOperations.begin_purge": "Microsoft.ApiManagement.DeletedServiceContracts.purge", + "azure.mgmt.apimanagement.aio.operations.DeletedServicesOperations.begin_purge": "Microsoft.ApiManagement.DeletedServiceContracts.purge", + "azure.mgmt.apimanagement.operations.DeletedServicesOperations.list_by_subscription": "Microsoft.ApiManagement.DeletedServicesOperationGroup.listBySubscription", + "azure.mgmt.apimanagement.aio.operations.DeletedServicesOperations.list_by_subscription": "Microsoft.ApiManagement.DeletedServicesOperationGroup.listBySubscription", + "azure.mgmt.apimanagement.operations.DocumentationOperations.get": "Microsoft.ApiManagement.DocumentationContracts.get", + "azure.mgmt.apimanagement.aio.operations.DocumentationOperations.get": "Microsoft.ApiManagement.DocumentationContracts.get", + "azure.mgmt.apimanagement.operations.DocumentationOperations.get_entity_tag": "Microsoft.ApiManagement.DocumentationContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.DocumentationOperations.get_entity_tag": "Microsoft.ApiManagement.DocumentationContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.DocumentationOperations.create_or_update": "Microsoft.ApiManagement.DocumentationContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.DocumentationOperations.create_or_update": "Microsoft.ApiManagement.DocumentationContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.DocumentationOperations.update": "Microsoft.ApiManagement.DocumentationContracts.update", + "azure.mgmt.apimanagement.aio.operations.DocumentationOperations.update": "Microsoft.ApiManagement.DocumentationContracts.update", + "azure.mgmt.apimanagement.operations.DocumentationOperations.delete": "Microsoft.ApiManagement.DocumentationContracts.delete", + "azure.mgmt.apimanagement.aio.operations.DocumentationOperations.delete": "Microsoft.ApiManagement.DocumentationContracts.delete", + "azure.mgmt.apimanagement.operations.DocumentationOperations.list_by_service": "Microsoft.ApiManagement.DocumentationContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.DocumentationOperations.list_by_service": "Microsoft.ApiManagement.DocumentationContracts.listByService", + "azure.mgmt.apimanagement.operations.EmailTemplateOperations.get": "Microsoft.ApiManagement.EmailTemplateContracts.get", + "azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations.get": "Microsoft.ApiManagement.EmailTemplateContracts.get", + "azure.mgmt.apimanagement.operations.EmailTemplateOperations.get_entity_tag": "Microsoft.ApiManagement.EmailTemplateContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations.get_entity_tag": "Microsoft.ApiManagement.EmailTemplateContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.EmailTemplateOperations.create_or_update": "Microsoft.ApiManagement.EmailTemplateContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations.create_or_update": "Microsoft.ApiManagement.EmailTemplateContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.EmailTemplateOperations.update": "Microsoft.ApiManagement.EmailTemplateContracts.update", + "azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations.update": "Microsoft.ApiManagement.EmailTemplateContracts.update", + "azure.mgmt.apimanagement.operations.EmailTemplateOperations.delete": "Microsoft.ApiManagement.EmailTemplateContracts.delete", + "azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations.delete": "Microsoft.ApiManagement.EmailTemplateContracts.delete", + "azure.mgmt.apimanagement.operations.EmailTemplateOperations.list_by_service": "Microsoft.ApiManagement.EmailTemplateContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations.list_by_service": "Microsoft.ApiManagement.EmailTemplateContracts.listByService", + "azure.mgmt.apimanagement.operations.ApiGatewayConfigConnectionOperations.get": "Microsoft.ApiManagement.ApiManagementGatewayConfigConnectionResources.get", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayConfigConnectionOperations.get": "Microsoft.ApiManagement.ApiManagementGatewayConfigConnectionResources.get", + "azure.mgmt.apimanagement.operations.ApiGatewayConfigConnectionOperations.begin_create_or_update": "Microsoft.ApiManagement.ApiManagementGatewayConfigConnectionResources.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayConfigConnectionOperations.begin_create_or_update": "Microsoft.ApiManagement.ApiManagementGatewayConfigConnectionResources.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiGatewayConfigConnectionOperations.begin_delete": "Microsoft.ApiManagement.ApiManagementGatewayConfigConnectionResources.delete", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayConfigConnectionOperations.begin_delete": "Microsoft.ApiManagement.ApiManagementGatewayConfigConnectionResources.delete", + "azure.mgmt.apimanagement.operations.ApiGatewayConfigConnectionOperations.list_by_gateway": "Microsoft.ApiManagement.ApiManagementGatewayConfigConnectionResources.listByGateway", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayConfigConnectionOperations.list_by_gateway": "Microsoft.ApiManagement.ApiManagementGatewayConfigConnectionResources.listByGateway", + "azure.mgmt.apimanagement.operations.ApiGatewayHostnameBindingOperations.get": "Microsoft.ApiManagement.GatewayHostnameBindingResources.get", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayHostnameBindingOperations.get": "Microsoft.ApiManagement.GatewayHostnameBindingResources.get", + "azure.mgmt.apimanagement.operations.ApiGatewayHostnameBindingOperations.begin_create_or_update": "Microsoft.ApiManagement.GatewayHostnameBindingResources.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayHostnameBindingOperations.begin_create_or_update": "Microsoft.ApiManagement.GatewayHostnameBindingResources.createOrUpdate", + "azure.mgmt.apimanagement.operations.ApiGatewayHostnameBindingOperations.begin_delete": "Microsoft.ApiManagement.GatewayHostnameBindingResources.delete", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayHostnameBindingOperations.begin_delete": "Microsoft.ApiManagement.GatewayHostnameBindingResources.delete", + "azure.mgmt.apimanagement.operations.ApiGatewayHostnameBindingOperations.list_by_gateway": "Microsoft.ApiManagement.GatewayHostnameBindingResources.listByGateway", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayHostnameBindingOperations.list_by_gateway": "Microsoft.ApiManagement.GatewayHostnameBindingResources.listByGateway", + "azure.mgmt.apimanagement.operations.ApiGatewayHostnameBindingOperations.begin_refresh_secret": "Microsoft.ApiManagement.GatewayHostnameBindingResources.refreshSecret", + "azure.mgmt.apimanagement.aio.operations.ApiGatewayHostnameBindingOperations.begin_refresh_secret": "Microsoft.ApiManagement.GatewayHostnameBindingResources.refreshSecret", + "azure.mgmt.apimanagement.operations.GatewayOperations.get": "Microsoft.ApiManagement.GatewayContracts.get", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.get": "Microsoft.ApiManagement.GatewayContracts.get", + "azure.mgmt.apimanagement.operations.GatewayOperations.get_entity_tag": "Microsoft.ApiManagement.GatewayContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.get_entity_tag": "Microsoft.ApiManagement.GatewayContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.GatewayOperations.create_or_update": "Microsoft.ApiManagement.GatewayContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.create_or_update": "Microsoft.ApiManagement.GatewayContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.GatewayOperations.update": "Microsoft.ApiManagement.GatewayContracts.update", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.update": "Microsoft.ApiManagement.GatewayContracts.update", + "azure.mgmt.apimanagement.operations.GatewayOperations.delete": "Microsoft.ApiManagement.GatewayContracts.delete", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.delete": "Microsoft.ApiManagement.GatewayContracts.delete", + "azure.mgmt.apimanagement.operations.GatewayOperations.list_by_service": "Microsoft.ApiManagement.GatewayContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.list_by_service": "Microsoft.ApiManagement.GatewayContracts.listByService", + "azure.mgmt.apimanagement.operations.GatewayOperations.list_keys": "Microsoft.ApiManagement.GatewayContracts.listKeys", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.list_keys": "Microsoft.ApiManagement.GatewayContracts.listKeys", + "azure.mgmt.apimanagement.operations.GatewayOperations.regenerate_key": "Microsoft.ApiManagement.GatewayContracts.regenerateKey", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.regenerate_key": "Microsoft.ApiManagement.GatewayContracts.regenerateKey", + "azure.mgmt.apimanagement.operations.GatewayOperations.generate_token": "Microsoft.ApiManagement.GatewayContracts.generateToken", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.generate_token": "Microsoft.ApiManagement.GatewayContracts.generateToken", + "azure.mgmt.apimanagement.operations.GatewayOperations.invalidate_debug_credentials": "Microsoft.ApiManagement.GatewayContracts.invalidateDebugCredentials", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.invalidate_debug_credentials": "Microsoft.ApiManagement.GatewayContracts.invalidateDebugCredentials", + "azure.mgmt.apimanagement.operations.GatewayOperations.list_debug_credentials": "Microsoft.ApiManagement.GatewayContracts.listDebugCredentials", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.list_debug_credentials": "Microsoft.ApiManagement.GatewayContracts.listDebugCredentials", + "azure.mgmt.apimanagement.operations.GatewayOperations.list_trace": "Microsoft.ApiManagement.GatewayContracts.listTrace", + "azure.mgmt.apimanagement.aio.operations.GatewayOperations.list_trace": "Microsoft.ApiManagement.GatewayContracts.listTrace", + "azure.mgmt.apimanagement.operations.GatewayApiOperations.list_by_service": "Microsoft.ApiManagement.GatewayContracts.gatewayApiListByService", + "azure.mgmt.apimanagement.aio.operations.GatewayApiOperations.list_by_service": "Microsoft.ApiManagement.GatewayContracts.gatewayApiListByService", + "azure.mgmt.apimanagement.operations.GatewayApiOperations.get_entity_tag": "Microsoft.ApiManagement.GatewayContracts.gatewayApiGetEntityTag", + "azure.mgmt.apimanagement.aio.operations.GatewayApiOperations.get_entity_tag": "Microsoft.ApiManagement.GatewayContracts.gatewayApiGetEntityTag", + "azure.mgmt.apimanagement.operations.GatewayApiOperations.create_or_update": "Microsoft.ApiManagement.GatewayContracts.gatewayApiCreateOrUpdate", + "azure.mgmt.apimanagement.aio.operations.GatewayApiOperations.create_or_update": "Microsoft.ApiManagement.GatewayContracts.gatewayApiCreateOrUpdate", + "azure.mgmt.apimanagement.operations.GatewayApiOperations.delete": "Microsoft.ApiManagement.GatewayContracts.gatewayApiDelete", + "azure.mgmt.apimanagement.aio.operations.GatewayApiOperations.delete": "Microsoft.ApiManagement.GatewayContracts.gatewayApiDelete", + "azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations.get": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.get", + "azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations.get": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.get", + "azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations.get_entity_tag": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations.get_entity_tag": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations.create_or_update": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations.create_or_update": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations.delete": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.delete", + "azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations.delete": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.delete", + "azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations.list_by_service": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations.list_by_service": "Microsoft.ApiManagement.GatewayHostnameConfigurationContracts.listByService", + "azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations.get": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.get", + "azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations.get": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.get", + "azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations.get_entity_tag": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations.get_entity_tag": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations.create_or_update": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations.create_or_update": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations.delete": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.delete", + "azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations.delete": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.delete", + "azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations.list_by_service": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations.list_by_service": "Microsoft.ApiManagement.GatewayCertificateAuthorityContracts.listByService", + "azure.mgmt.apimanagement.operations.GroupOperations.get": "Microsoft.ApiManagement.GroupContracts.get", + "azure.mgmt.apimanagement.aio.operations.GroupOperations.get": "Microsoft.ApiManagement.GroupContracts.get", + "azure.mgmt.apimanagement.operations.GroupOperations.get_entity_tag": "Microsoft.ApiManagement.GroupContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.GroupOperations.get_entity_tag": "Microsoft.ApiManagement.GroupContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.GroupOperations.create_or_update": "Microsoft.ApiManagement.GroupContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.GroupOperations.create_or_update": "Microsoft.ApiManagement.GroupContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.GroupOperations.update": "Microsoft.ApiManagement.GroupContracts.update", + "azure.mgmt.apimanagement.aio.operations.GroupOperations.update": "Microsoft.ApiManagement.GroupContracts.update", + "azure.mgmt.apimanagement.operations.GroupOperations.delete": "Microsoft.ApiManagement.GroupContracts.delete", + "azure.mgmt.apimanagement.aio.operations.GroupOperations.delete": "Microsoft.ApiManagement.GroupContracts.delete", + "azure.mgmt.apimanagement.operations.GroupOperations.list_by_service": "Microsoft.ApiManagement.GroupContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.GroupOperations.list_by_service": "Microsoft.ApiManagement.GroupContracts.listByService", + "azure.mgmt.apimanagement.operations.GroupUserOperations.list": "Microsoft.ApiManagement.GroupContracts.list", + "azure.mgmt.apimanagement.aio.operations.GroupUserOperations.list": "Microsoft.ApiManagement.GroupContracts.list", + "azure.mgmt.apimanagement.operations.GroupUserOperations.check_entity_exists": "Microsoft.ApiManagement.GroupContracts.checkEntityExists", + "azure.mgmt.apimanagement.aio.operations.GroupUserOperations.check_entity_exists": "Microsoft.ApiManagement.GroupContracts.checkEntityExists", + "azure.mgmt.apimanagement.operations.GroupUserOperations.create": "Microsoft.ApiManagement.GroupContracts.create", + "azure.mgmt.apimanagement.aio.operations.GroupUserOperations.create": "Microsoft.ApiManagement.GroupContracts.create", + "azure.mgmt.apimanagement.operations.GroupUserOperations.delete": "Microsoft.ApiManagement.GroupContracts.groupUserDelete", + "azure.mgmt.apimanagement.aio.operations.GroupUserOperations.delete": "Microsoft.ApiManagement.GroupContracts.groupUserDelete", + "azure.mgmt.apimanagement.operations.WorkspaceGroupUserOperations.list": "Microsoft.ApiManagement.WorkspaceGroup.list", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupUserOperations.list": "Microsoft.ApiManagement.WorkspaceGroup.list", + "azure.mgmt.apimanagement.operations.WorkspaceGroupUserOperations.check_entity_exists": "Microsoft.ApiManagement.WorkspaceGroup.checkEntityExists", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupUserOperations.check_entity_exists": "Microsoft.ApiManagement.WorkspaceGroup.checkEntityExists", + "azure.mgmt.apimanagement.operations.WorkspaceGroupUserOperations.create": "Microsoft.ApiManagement.WorkspaceGroup.create", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupUserOperations.create": "Microsoft.ApiManagement.WorkspaceGroup.create", + "azure.mgmt.apimanagement.operations.WorkspaceGroupUserOperations.delete": "Microsoft.ApiManagement.WorkspaceGroup.workspaceGroupUserDelete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceGroupUserOperations.delete": "Microsoft.ApiManagement.WorkspaceGroup.workspaceGroupUserDelete", + "azure.mgmt.apimanagement.operations.IdentityProviderOperations.get": "Microsoft.ApiManagement.IdentityProviderContracts.get", + "azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations.get": "Microsoft.ApiManagement.IdentityProviderContracts.get", + "azure.mgmt.apimanagement.operations.IdentityProviderOperations.get_entity_tag": "Microsoft.ApiManagement.IdentityProviderContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations.get_entity_tag": "Microsoft.ApiManagement.IdentityProviderContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.IdentityProviderOperations.create_or_update": "Microsoft.ApiManagement.IdentityProviderContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations.create_or_update": "Microsoft.ApiManagement.IdentityProviderContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.IdentityProviderOperations.update": "Microsoft.ApiManagement.IdentityProviderContracts.update", + "azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations.update": "Microsoft.ApiManagement.IdentityProviderContracts.update", + "azure.mgmt.apimanagement.operations.IdentityProviderOperations.delete": "Microsoft.ApiManagement.IdentityProviderContracts.delete", + "azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations.delete": "Microsoft.ApiManagement.IdentityProviderContracts.delete", + "azure.mgmt.apimanagement.operations.IdentityProviderOperations.list_by_service": "Microsoft.ApiManagement.IdentityProviderContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations.list_by_service": "Microsoft.ApiManagement.IdentityProviderContracts.listByService", + "azure.mgmt.apimanagement.operations.IdentityProviderOperations.list_secrets": "Microsoft.ApiManagement.IdentityProviderContracts.listSecrets", + "azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations.list_secrets": "Microsoft.ApiManagement.IdentityProviderContracts.listSecrets", + "azure.mgmt.apimanagement.operations.LoggerOperations.get": "Microsoft.ApiManagement.LoggerContracts.get", + "azure.mgmt.apimanagement.aio.operations.LoggerOperations.get": "Microsoft.ApiManagement.LoggerContracts.get", + "azure.mgmt.apimanagement.operations.LoggerOperations.get_entity_tag": "Microsoft.ApiManagement.LoggerContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.LoggerOperations.get_entity_tag": "Microsoft.ApiManagement.LoggerContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.LoggerOperations.create_or_update": "Microsoft.ApiManagement.LoggerContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.LoggerOperations.create_or_update": "Microsoft.ApiManagement.LoggerContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.LoggerOperations.update": "Microsoft.ApiManagement.LoggerContracts.update", + "azure.mgmt.apimanagement.aio.operations.LoggerOperations.update": "Microsoft.ApiManagement.LoggerContracts.update", + "azure.mgmt.apimanagement.operations.LoggerOperations.delete": "Microsoft.ApiManagement.LoggerContracts.delete", + "azure.mgmt.apimanagement.aio.operations.LoggerOperations.delete": "Microsoft.ApiManagement.LoggerContracts.delete", + "azure.mgmt.apimanagement.operations.LoggerOperations.list_by_service": "Microsoft.ApiManagement.LoggerContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.LoggerOperations.list_by_service": "Microsoft.ApiManagement.LoggerContracts.listByService", + "azure.mgmt.apimanagement.operations.NamedValueOperations.get": "Microsoft.ApiManagement.NamedValueContracts.get", + "azure.mgmt.apimanagement.aio.operations.NamedValueOperations.get": "Microsoft.ApiManagement.NamedValueContracts.get", + "azure.mgmt.apimanagement.operations.NamedValueOperations.get_entity_tag": "Microsoft.ApiManagement.NamedValueContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.NamedValueOperations.get_entity_tag": "Microsoft.ApiManagement.NamedValueContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.NamedValueOperations.begin_create_or_update": "Microsoft.ApiManagement.NamedValueContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.NamedValueOperations.begin_create_or_update": "Microsoft.ApiManagement.NamedValueContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.NamedValueOperations.begin_update": "Microsoft.ApiManagement.NamedValueContracts.update", + "azure.mgmt.apimanagement.aio.operations.NamedValueOperations.begin_update": "Microsoft.ApiManagement.NamedValueContracts.update", + "azure.mgmt.apimanagement.operations.NamedValueOperations.delete": "Microsoft.ApiManagement.NamedValueContracts.delete", + "azure.mgmt.apimanagement.aio.operations.NamedValueOperations.delete": "Microsoft.ApiManagement.NamedValueContracts.delete", + "azure.mgmt.apimanagement.operations.NamedValueOperations.list_by_service": "Microsoft.ApiManagement.NamedValueContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.NamedValueOperations.list_by_service": "Microsoft.ApiManagement.NamedValueContracts.listByService", + "azure.mgmt.apimanagement.operations.NamedValueOperations.list_value": "Microsoft.ApiManagement.NamedValueContracts.listValue", + "azure.mgmt.apimanagement.aio.operations.NamedValueOperations.list_value": "Microsoft.ApiManagement.NamedValueContracts.listValue", + "azure.mgmt.apimanagement.operations.NamedValueOperations.begin_refresh_secret": "Microsoft.ApiManagement.NamedValueContracts.refreshSecret", + "azure.mgmt.apimanagement.aio.operations.NamedValueOperations.begin_refresh_secret": "Microsoft.ApiManagement.NamedValueContracts.refreshSecret", + "azure.mgmt.apimanagement.operations.NotificationOperations.get": "Microsoft.ApiManagement.NotificationContracts.get", + "azure.mgmt.apimanagement.aio.operations.NotificationOperations.get": "Microsoft.ApiManagement.NotificationContracts.get", + "azure.mgmt.apimanagement.operations.NotificationOperations.create_or_update": "Microsoft.ApiManagement.NotificationContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.NotificationOperations.create_or_update": "Microsoft.ApiManagement.NotificationContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.NotificationOperations.list_by_service": "Microsoft.ApiManagement.NotificationContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.NotificationOperations.list_by_service": "Microsoft.ApiManagement.NotificationContracts.listByService", + "azure.mgmt.apimanagement.operations.NotificationRecipientUserOperations.list_by_notification": "Microsoft.ApiManagement.NotificationContracts.listByNotification", + "azure.mgmt.apimanagement.aio.operations.NotificationRecipientUserOperations.list_by_notification": "Microsoft.ApiManagement.NotificationContracts.listByNotification", + "azure.mgmt.apimanagement.operations.NotificationRecipientUserOperations.check_entity_exists": "Microsoft.ApiManagement.NotificationContracts.checkEntityExists", + "azure.mgmt.apimanagement.aio.operations.NotificationRecipientUserOperations.check_entity_exists": "Microsoft.ApiManagement.NotificationContracts.checkEntityExists", + "azure.mgmt.apimanagement.operations.NotificationRecipientUserOperations.create_or_update": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientUserCreateOrUpdate", + "azure.mgmt.apimanagement.aio.operations.NotificationRecipientUserOperations.create_or_update": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientUserCreateOrUpdate", + "azure.mgmt.apimanagement.operations.NotificationRecipientUserOperations.delete": "Microsoft.ApiManagement.NotificationContracts.delete", + "azure.mgmt.apimanagement.aio.operations.NotificationRecipientUserOperations.delete": "Microsoft.ApiManagement.NotificationContracts.delete", + "azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations.list_by_notification": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientEmailListByNotification", + "azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations.list_by_notification": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientEmailListByNotification", + "azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations.check_entity_exists": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientEmailCheckEntityExists", + "azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations.check_entity_exists": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientEmailCheckEntityExists", + "azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations.create_or_update": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientEmailCreateOrUpdate", + "azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations.create_or_update": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientEmailCreateOrUpdate", + "azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations.delete": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientEmailDelete", + "azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations.delete": "Microsoft.ApiManagement.NotificationContracts.notificationRecipientEmailDelete", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientUserOperations.list_by_notification": "Microsoft.ApiManagement.WorkspaceNotification.listByNotification", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientUserOperations.list_by_notification": "Microsoft.ApiManagement.WorkspaceNotification.listByNotification", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientUserOperations.check_entity_exists": "Microsoft.ApiManagement.WorkspaceNotification.checkEntityExists", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientUserOperations.check_entity_exists": "Microsoft.ApiManagement.WorkspaceNotification.checkEntityExists", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientUserOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientUserCreateOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientUserOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientUserCreateOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientUserOperations.delete": "Microsoft.ApiManagement.WorkspaceNotification.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientUserOperations.delete": "Microsoft.ApiManagement.WorkspaceNotification.delete", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientEmailOperations.list_by_notification": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientEmailListByNotification", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientEmailOperations.list_by_notification": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientEmailListByNotification", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientEmailOperations.check_entity_exists": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientEmailCheckEntityExists", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientEmailOperations.check_entity_exists": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientEmailCheckEntityExists", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientEmailOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientEmailCreateOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientEmailOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientEmailCreateOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceNotificationRecipientEmailOperations.delete": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientEmailDelete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationRecipientEmailOperations.delete": "Microsoft.ApiManagement.WorkspaceNotification.workspaceNotificationRecipientEmailDelete", + "azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations.get": "Microsoft.ApiManagement.OpenidConnectProviderContracts.get", + "azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations.get": "Microsoft.ApiManagement.OpenidConnectProviderContracts.get", + "azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations.get_entity_tag": "Microsoft.ApiManagement.OpenidConnectProviderContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations.get_entity_tag": "Microsoft.ApiManagement.OpenidConnectProviderContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations.create_or_update": "Microsoft.ApiManagement.OpenidConnectProviderContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations.create_or_update": "Microsoft.ApiManagement.OpenidConnectProviderContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations.update": "Microsoft.ApiManagement.OpenidConnectProviderContracts.update", + "azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations.update": "Microsoft.ApiManagement.OpenidConnectProviderContracts.update", + "azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations.delete": "Microsoft.ApiManagement.OpenidConnectProviderContracts.delete", + "azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations.delete": "Microsoft.ApiManagement.OpenidConnectProviderContracts.delete", + "azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations.list_by_service": "Microsoft.ApiManagement.OpenidConnectProviderContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations.list_by_service": "Microsoft.ApiManagement.OpenidConnectProviderContracts.listByService", + "azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations.list_secrets": "Microsoft.ApiManagement.OpenidConnectProviderContracts.listSecrets", + "azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations.list_secrets": "Microsoft.ApiManagement.OpenidConnectProviderContracts.listSecrets", + "azure.mgmt.apimanagement.operations.PolicyFragmentOperations.get": "Microsoft.ApiManagement.PolicyFragmentContracts.get", + "azure.mgmt.apimanagement.aio.operations.PolicyFragmentOperations.get": "Microsoft.ApiManagement.PolicyFragmentContracts.get", + "azure.mgmt.apimanagement.operations.PolicyFragmentOperations.get_entity_tag": "Microsoft.ApiManagement.PolicyFragmentContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.PolicyFragmentOperations.get_entity_tag": "Microsoft.ApiManagement.PolicyFragmentContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.PolicyFragmentOperations.begin_create_or_update": "Microsoft.ApiManagement.PolicyFragmentContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.PolicyFragmentOperations.begin_create_or_update": "Microsoft.ApiManagement.PolicyFragmentContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.PolicyFragmentOperations.delete": "Microsoft.ApiManagement.PolicyFragmentContracts.delete", + "azure.mgmt.apimanagement.aio.operations.PolicyFragmentOperations.delete": "Microsoft.ApiManagement.PolicyFragmentContracts.delete", + "azure.mgmt.apimanagement.operations.PolicyFragmentOperations.list_by_service": "Microsoft.ApiManagement.PolicyFragmentContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.PolicyFragmentOperations.list_by_service": "Microsoft.ApiManagement.PolicyFragmentContracts.listByService", + "azure.mgmt.apimanagement.operations.PolicyFragmentOperations.list_references": "Microsoft.ApiManagement.PolicyFragmentContracts.listReferences", + "azure.mgmt.apimanagement.aio.operations.PolicyFragmentOperations.list_references": "Microsoft.ApiManagement.PolicyFragmentContracts.listReferences", + "azure.mgmt.apimanagement.operations.PolicyRestrictionOperations.get": "Microsoft.ApiManagement.PolicyRestrictionContracts.get", + "azure.mgmt.apimanagement.aio.operations.PolicyRestrictionOperations.get": "Microsoft.ApiManagement.PolicyRestrictionContracts.get", + "azure.mgmt.apimanagement.operations.PolicyRestrictionOperations.get_entity_tag": "Microsoft.ApiManagement.PolicyRestrictionContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.PolicyRestrictionOperations.get_entity_tag": "Microsoft.ApiManagement.PolicyRestrictionContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.PolicyRestrictionOperations.create_or_update": "Microsoft.ApiManagement.PolicyRestrictionContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.PolicyRestrictionOperations.create_or_update": "Microsoft.ApiManagement.PolicyRestrictionContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.PolicyRestrictionOperations.update": "Microsoft.ApiManagement.PolicyRestrictionContracts.update", + "azure.mgmt.apimanagement.aio.operations.PolicyRestrictionOperations.update": "Microsoft.ApiManagement.PolicyRestrictionContracts.update", + "azure.mgmt.apimanagement.operations.PolicyRestrictionOperations.delete": "Microsoft.ApiManagement.PolicyRestrictionContracts.delete", + "azure.mgmt.apimanagement.aio.operations.PolicyRestrictionOperations.delete": "Microsoft.ApiManagement.PolicyRestrictionContracts.delete", + "azure.mgmt.apimanagement.operations.PolicyRestrictionOperations.list_by_service": "Microsoft.ApiManagement.PolicyRestrictionContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.PolicyRestrictionOperations.list_by_service": "Microsoft.ApiManagement.PolicyRestrictionContracts.listByService", + "azure.mgmt.apimanagement.operations.PortalConfigOperations.get": "Microsoft.ApiManagement.PortalConfigContracts.get", + "azure.mgmt.apimanagement.aio.operations.PortalConfigOperations.get": "Microsoft.ApiManagement.PortalConfigContracts.get", + "azure.mgmt.apimanagement.operations.PortalConfigOperations.get_entity_tag": "Microsoft.ApiManagement.PortalConfigContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.PortalConfigOperations.get_entity_tag": "Microsoft.ApiManagement.PortalConfigContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.PortalConfigOperations.create_or_update": "Microsoft.ApiManagement.PortalConfigContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.PortalConfigOperations.create_or_update": "Microsoft.ApiManagement.PortalConfigContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.PortalConfigOperations.update": "Microsoft.ApiManagement.PortalConfigContracts.update", + "azure.mgmt.apimanagement.aio.operations.PortalConfigOperations.update": "Microsoft.ApiManagement.PortalConfigContracts.update", + "azure.mgmt.apimanagement.operations.PortalConfigOperations.list_by_service": "Microsoft.ApiManagement.PortalConfigContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.PortalConfigOperations.list_by_service": "Microsoft.ApiManagement.PortalConfigContracts.listByService", + "azure.mgmt.apimanagement.operations.ClientApplicationOperations.get": "Microsoft.ApiManagement.ClientApplicationContracts.get", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationOperations.get": "Microsoft.ApiManagement.ClientApplicationContracts.get", + "azure.mgmt.apimanagement.operations.ClientApplicationOperations.get_entity_tag": "Microsoft.ApiManagement.ClientApplicationContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationOperations.get_entity_tag": "Microsoft.ApiManagement.ClientApplicationContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.ClientApplicationOperations.create_or_update": "Microsoft.ApiManagement.ClientApplicationContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationOperations.create_or_update": "Microsoft.ApiManagement.ClientApplicationContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ClientApplicationOperations.delete": "Microsoft.ApiManagement.ClientApplicationContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationOperations.delete": "Microsoft.ApiManagement.ClientApplicationContracts.delete", + "azure.mgmt.apimanagement.operations.ClientApplicationOperations.list_by_service": "Microsoft.ApiManagement.ClientApplicationContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationOperations.list_by_service": "Microsoft.ApiManagement.ClientApplicationContracts.listByService", + "azure.mgmt.apimanagement.operations.ClientApplicationOperations.list_secrets": "Microsoft.ApiManagement.ClientApplicationContracts.listSecrets", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationOperations.list_secrets": "Microsoft.ApiManagement.ClientApplicationContracts.listSecrets", + "azure.mgmt.apimanagement.operations.ClientApplicationProductLinkOperations.get": "Microsoft.ApiManagement.ClientApplicationProductLinkContracts.get", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationProductLinkOperations.get": "Microsoft.ApiManagement.ClientApplicationProductLinkContracts.get", + "azure.mgmt.apimanagement.operations.ClientApplicationProductLinkOperations.create": "Microsoft.ApiManagement.ClientApplicationProductLinkContracts.create", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationProductLinkOperations.create": "Microsoft.ApiManagement.ClientApplicationProductLinkContracts.create", + "azure.mgmt.apimanagement.operations.ClientApplicationProductLinkOperations.delete": "Microsoft.ApiManagement.ClientApplicationProductLinkContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationProductLinkOperations.delete": "Microsoft.ApiManagement.ClientApplicationProductLinkContracts.delete", + "azure.mgmt.apimanagement.operations.ClientApplicationProductLinkOperations.list_by_client_applications": "Microsoft.ApiManagement.ClientApplicationProductLinkContracts.listByClientApplications", + "azure.mgmt.apimanagement.aio.operations.ClientApplicationProductLinkOperations.list_by_client_applications": "Microsoft.ApiManagement.ClientApplicationProductLinkContracts.listByClientApplications", + "azure.mgmt.apimanagement.operations.PortalRevisionOperations.get": "Microsoft.ApiManagement.PortalRevisionContracts.get", + "azure.mgmt.apimanagement.aio.operations.PortalRevisionOperations.get": "Microsoft.ApiManagement.PortalRevisionContracts.get", + "azure.mgmt.apimanagement.operations.PortalRevisionOperations.get_entity_tag": "Microsoft.ApiManagement.PortalRevisionContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.PortalRevisionOperations.get_entity_tag": "Microsoft.ApiManagement.PortalRevisionContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.PortalRevisionOperations.begin_create_or_update": "Microsoft.ApiManagement.PortalRevisionContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.PortalRevisionOperations.begin_create_or_update": "Microsoft.ApiManagement.PortalRevisionContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.PortalRevisionOperations.begin_update": "Microsoft.ApiManagement.PortalRevisionContracts.update", + "azure.mgmt.apimanagement.aio.operations.PortalRevisionOperations.begin_update": "Microsoft.ApiManagement.PortalRevisionContracts.update", + "azure.mgmt.apimanagement.operations.PortalRevisionOperations.list_by_service": "Microsoft.ApiManagement.PortalRevisionContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.PortalRevisionOperations.list_by_service": "Microsoft.ApiManagement.PortalRevisionContracts.listByService", + "azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations.get_by_name": "Microsoft.ApiManagement.PrivateEndpointConnections.getByName", + "azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations.get_by_name": "Microsoft.ApiManagement.PrivateEndpointConnections.getByName", + "azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations.begin_create_or_update": "Microsoft.ApiManagement.PrivateEndpointConnections.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations.begin_create_or_update": "Microsoft.ApiManagement.PrivateEndpointConnections.createOrUpdate", + "azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations.begin_delete": "Microsoft.ApiManagement.PrivateEndpointConnections.delete", + "azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations.begin_delete": "Microsoft.ApiManagement.PrivateEndpointConnections.delete", + "azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations.list_by_service": "Microsoft.ApiManagement.PrivateEndpointConnections.listByService", + "azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations.list_by_service": "Microsoft.ApiManagement.PrivateEndpointConnections.listByService", + "azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations.get_private_link_resource": "Microsoft.ApiManagement.PrivateLinkResources.getPrivateLinkResource", + "azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations.get_private_link_resource": "Microsoft.ApiManagement.PrivateLinkResources.getPrivateLinkResource", + "azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations.list_private_link_resources": "Microsoft.ApiManagement.PrivateLinkResources.listPrivateLinkResources", + "azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations.list_private_link_resources": "Microsoft.ApiManagement.PrivateLinkResources.listPrivateLinkResources", + "azure.mgmt.apimanagement.operations.ProductApiOperations.list_by_product": "Microsoft.ApiManagement.ProductContracts.listByProduct", + "azure.mgmt.apimanagement.aio.operations.ProductApiOperations.list_by_product": "Microsoft.ApiManagement.ProductContracts.listByProduct", + "azure.mgmt.apimanagement.operations.ProductApiOperations.check_entity_exists": "Microsoft.ApiManagement.ProductContracts.checkEntityExists", + "azure.mgmt.apimanagement.aio.operations.ProductApiOperations.check_entity_exists": "Microsoft.ApiManagement.ProductContracts.checkEntityExists", + "azure.mgmt.apimanagement.operations.ProductApiOperations.create_or_update": "Microsoft.ApiManagement.ProductContracts.productApiCreateOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ProductApiOperations.create_or_update": "Microsoft.ApiManagement.ProductContracts.productApiCreateOrUpdate", + "azure.mgmt.apimanagement.operations.ProductApiOperations.delete": "Microsoft.ApiManagement.ProductContracts.productApiDelete", + "azure.mgmt.apimanagement.aio.operations.ProductApiOperations.delete": "Microsoft.ApiManagement.ProductContracts.productApiDelete", + "azure.mgmt.apimanagement.operations.ProductGroupOperations.list_by_product": "Microsoft.ApiManagement.ProductContracts.productGroupListByProduct", + "azure.mgmt.apimanagement.aio.operations.ProductGroupOperations.list_by_product": "Microsoft.ApiManagement.ProductContracts.productGroupListByProduct", + "azure.mgmt.apimanagement.operations.ProductGroupOperations.check_entity_exists": "Microsoft.ApiManagement.ProductContracts.productGroupCheckEntityExists", + "azure.mgmt.apimanagement.aio.operations.ProductGroupOperations.check_entity_exists": "Microsoft.ApiManagement.ProductContracts.productGroupCheckEntityExists", + "azure.mgmt.apimanagement.operations.ProductGroupOperations.create_or_update": "Microsoft.ApiManagement.ProductContracts.productGroupCreateOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ProductGroupOperations.create_or_update": "Microsoft.ApiManagement.ProductContracts.productGroupCreateOrUpdate", + "azure.mgmt.apimanagement.operations.ProductGroupOperations.delete": "Microsoft.ApiManagement.ProductContracts.productGroupDelete", + "azure.mgmt.apimanagement.aio.operations.ProductGroupOperations.delete": "Microsoft.ApiManagement.ProductContracts.productGroupDelete", + "azure.mgmt.apimanagement.operations.ProductSubscriptionsOperations.list": "Microsoft.ApiManagement.ProductContracts.list", + "azure.mgmt.apimanagement.aio.operations.ProductSubscriptionsOperations.list": "Microsoft.ApiManagement.ProductContracts.list", + "azure.mgmt.apimanagement.operations.ProductApiLinkOperations.get": "Microsoft.ApiManagement.ProductApiLinkContracts.get", + "azure.mgmt.apimanagement.aio.operations.ProductApiLinkOperations.get": "Microsoft.ApiManagement.ProductApiLinkContracts.get", + "azure.mgmt.apimanagement.operations.ProductApiLinkOperations.create_or_update": "Microsoft.ApiManagement.ProductApiLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ProductApiLinkOperations.create_or_update": "Microsoft.ApiManagement.ProductApiLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ProductApiLinkOperations.delete": "Microsoft.ApiManagement.ProductApiLinkContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ProductApiLinkOperations.delete": "Microsoft.ApiManagement.ProductApiLinkContracts.delete", + "azure.mgmt.apimanagement.operations.ProductApiLinkOperations.list_by_product": "Microsoft.ApiManagement.ProductApiLinkContracts.listByProduct", + "azure.mgmt.apimanagement.aio.operations.ProductApiLinkOperations.list_by_product": "Microsoft.ApiManagement.ProductApiLinkContracts.listByProduct", + "azure.mgmt.apimanagement.operations.ProductGroupLinkOperations.get": "Microsoft.ApiManagement.ProductGroupLinkContracts.get", + "azure.mgmt.apimanagement.aio.operations.ProductGroupLinkOperations.get": "Microsoft.ApiManagement.ProductGroupLinkContracts.get", + "azure.mgmt.apimanagement.operations.ProductGroupLinkOperations.create_or_update": "Microsoft.ApiManagement.ProductGroupLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.ProductGroupLinkOperations.create_or_update": "Microsoft.ApiManagement.ProductGroupLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.ProductGroupLinkOperations.delete": "Microsoft.ApiManagement.ProductGroupLinkContracts.delete", + "azure.mgmt.apimanagement.aio.operations.ProductGroupLinkOperations.delete": "Microsoft.ApiManagement.ProductGroupLinkContracts.delete", + "azure.mgmt.apimanagement.operations.ProductGroupLinkOperations.list_by_product": "Microsoft.ApiManagement.ProductGroupLinkContracts.listByProduct", + "azure.mgmt.apimanagement.aio.operations.ProductGroupLinkOperations.list_by_product": "Microsoft.ApiManagement.ProductGroupLinkContracts.listByProduct", + "azure.mgmt.apimanagement.operations.GlobalSchemaOperations.get": "Microsoft.ApiManagement.GlobalSchemaContracts.get", + "azure.mgmt.apimanagement.aio.operations.GlobalSchemaOperations.get": "Microsoft.ApiManagement.GlobalSchemaContracts.get", + "azure.mgmt.apimanagement.operations.GlobalSchemaOperations.get_entity_tag": "Microsoft.ApiManagement.GlobalSchemaContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.GlobalSchemaOperations.get_entity_tag": "Microsoft.ApiManagement.GlobalSchemaContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.GlobalSchemaOperations.begin_create_or_update": "Microsoft.ApiManagement.GlobalSchemaContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.GlobalSchemaOperations.begin_create_or_update": "Microsoft.ApiManagement.GlobalSchemaContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.GlobalSchemaOperations.delete": "Microsoft.ApiManagement.GlobalSchemaContracts.delete", + "azure.mgmt.apimanagement.aio.operations.GlobalSchemaOperations.delete": "Microsoft.ApiManagement.GlobalSchemaContracts.delete", + "azure.mgmt.apimanagement.operations.GlobalSchemaOperations.list_by_service": "Microsoft.ApiManagement.GlobalSchemaContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.GlobalSchemaOperations.list_by_service": "Microsoft.ApiManagement.GlobalSchemaContracts.listByService", + "azure.mgmt.apimanagement.operations.TenantSettingsOperations.get": "Microsoft.ApiManagement.TenantSettingsContracts.get", + "azure.mgmt.apimanagement.aio.operations.TenantSettingsOperations.get": "Microsoft.ApiManagement.TenantSettingsContracts.get", + "azure.mgmt.apimanagement.operations.TenantSettingsOperations.list_by_service": "Microsoft.ApiManagement.TenantSettingsContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.TenantSettingsOperations.list_by_service": "Microsoft.ApiManagement.TenantSettingsContracts.listByService", + "azure.mgmt.apimanagement.operations.SubscriptionOperations.get": "Microsoft.ApiManagement.SubscriptionContracts.get", + "azure.mgmt.apimanagement.aio.operations.SubscriptionOperations.get": "Microsoft.ApiManagement.SubscriptionContracts.get", + "azure.mgmt.apimanagement.operations.SubscriptionOperations.get_entity_tag": "Microsoft.ApiManagement.SubscriptionContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.SubscriptionOperations.get_entity_tag": "Microsoft.ApiManagement.SubscriptionContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.SubscriptionOperations.create_or_update": "Microsoft.ApiManagement.SubscriptionContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.SubscriptionOperations.create_or_update": "Microsoft.ApiManagement.SubscriptionContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.SubscriptionOperations.update": "Microsoft.ApiManagement.SubscriptionContracts.update", + "azure.mgmt.apimanagement.aio.operations.SubscriptionOperations.update": "Microsoft.ApiManagement.SubscriptionContracts.update", + "azure.mgmt.apimanagement.operations.SubscriptionOperations.delete": "Microsoft.ApiManagement.SubscriptionContracts.delete", + "azure.mgmt.apimanagement.aio.operations.SubscriptionOperations.delete": "Microsoft.ApiManagement.SubscriptionContracts.delete", + "azure.mgmt.apimanagement.operations.SubscriptionOperations.list": "Microsoft.ApiManagement.SubscriptionContracts.list", + "azure.mgmt.apimanagement.aio.operations.SubscriptionOperations.list": "Microsoft.ApiManagement.SubscriptionContracts.list", + "azure.mgmt.apimanagement.operations.SubscriptionOperations.regenerate_primary_key": "Microsoft.ApiManagement.SubscriptionContracts.regeneratePrimaryKey", + "azure.mgmt.apimanagement.aio.operations.SubscriptionOperations.regenerate_primary_key": "Microsoft.ApiManagement.SubscriptionContracts.regeneratePrimaryKey", + "azure.mgmt.apimanagement.operations.SubscriptionOperations.regenerate_secondary_key": "Microsoft.ApiManagement.SubscriptionContracts.regenerateSecondaryKey", + "azure.mgmt.apimanagement.aio.operations.SubscriptionOperations.regenerate_secondary_key": "Microsoft.ApiManagement.SubscriptionContracts.regenerateSecondaryKey", + "azure.mgmt.apimanagement.operations.SubscriptionOperations.list_secrets": "Microsoft.ApiManagement.SubscriptionContracts.listSecrets", + "azure.mgmt.apimanagement.aio.operations.SubscriptionOperations.list_secrets": "Microsoft.ApiManagement.SubscriptionContracts.listSecrets", + "azure.mgmt.apimanagement.operations.TagApiLinkOperations.get": "Microsoft.ApiManagement.TagApiLinkContracts.get", + "azure.mgmt.apimanagement.aio.operations.TagApiLinkOperations.get": "Microsoft.ApiManagement.TagApiLinkContracts.get", + "azure.mgmt.apimanagement.operations.TagApiLinkOperations.create_or_update": "Microsoft.ApiManagement.TagApiLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.TagApiLinkOperations.create_or_update": "Microsoft.ApiManagement.TagApiLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.TagApiLinkOperations.delete": "Microsoft.ApiManagement.TagApiLinkContracts.delete", + "azure.mgmt.apimanagement.aio.operations.TagApiLinkOperations.delete": "Microsoft.ApiManagement.TagApiLinkContracts.delete", + "azure.mgmt.apimanagement.operations.TagApiLinkOperations.list_by_product": "Microsoft.ApiManagement.TagApiLinkContracts.listByProduct", + "azure.mgmt.apimanagement.aio.operations.TagApiLinkOperations.list_by_product": "Microsoft.ApiManagement.TagApiLinkContracts.listByProduct", + "azure.mgmt.apimanagement.operations.TagOperationLinkOperations.get": "Microsoft.ApiManagement.TagOperationLinkContracts.get", + "azure.mgmt.apimanagement.aio.operations.TagOperationLinkOperations.get": "Microsoft.ApiManagement.TagOperationLinkContracts.get", + "azure.mgmt.apimanagement.operations.TagOperationLinkOperations.create_or_update": "Microsoft.ApiManagement.TagOperationLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.TagOperationLinkOperations.create_or_update": "Microsoft.ApiManagement.TagOperationLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.TagOperationLinkOperations.delete": "Microsoft.ApiManagement.TagOperationLinkContracts.delete", + "azure.mgmt.apimanagement.aio.operations.TagOperationLinkOperations.delete": "Microsoft.ApiManagement.TagOperationLinkContracts.delete", + "azure.mgmt.apimanagement.operations.TagOperationLinkOperations.list_by_product": "Microsoft.ApiManagement.TagOperationLinkContracts.listByProduct", + "azure.mgmt.apimanagement.aio.operations.TagOperationLinkOperations.list_by_product": "Microsoft.ApiManagement.TagOperationLinkContracts.listByProduct", + "azure.mgmt.apimanagement.operations.TagProductLinkOperations.get": "Microsoft.ApiManagement.TagProductLinkContracts.get", + "azure.mgmt.apimanagement.aio.operations.TagProductLinkOperations.get": "Microsoft.ApiManagement.TagProductLinkContracts.get", + "azure.mgmt.apimanagement.operations.TagProductLinkOperations.create_or_update": "Microsoft.ApiManagement.TagProductLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.TagProductLinkOperations.create_or_update": "Microsoft.ApiManagement.TagProductLinkContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.TagProductLinkOperations.delete": "Microsoft.ApiManagement.TagProductLinkContracts.delete", + "azure.mgmt.apimanagement.aio.operations.TagProductLinkOperations.delete": "Microsoft.ApiManagement.TagProductLinkContracts.delete", + "azure.mgmt.apimanagement.operations.TagProductLinkOperations.list_by_product": "Microsoft.ApiManagement.TagProductLinkContracts.listByProduct", + "azure.mgmt.apimanagement.aio.operations.TagProductLinkOperations.list_by_product": "Microsoft.ApiManagement.TagProductLinkContracts.listByProduct", + "azure.mgmt.apimanagement.operations.TenantAccessOperations.get": "Microsoft.ApiManagement.AccessInformationContracts.get", + "azure.mgmt.apimanagement.aio.operations.TenantAccessOperations.get": "Microsoft.ApiManagement.AccessInformationContracts.get", + "azure.mgmt.apimanagement.operations.TenantAccessOperations.get_entity_tag": "Microsoft.ApiManagement.AccessInformationContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.TenantAccessOperations.get_entity_tag": "Microsoft.ApiManagement.AccessInformationContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.TenantAccessOperations.create": "Microsoft.ApiManagement.AccessInformationContracts.create", + "azure.mgmt.apimanagement.aio.operations.TenantAccessOperations.create": "Microsoft.ApiManagement.AccessInformationContracts.create", + "azure.mgmt.apimanagement.operations.TenantAccessOperations.update": "Microsoft.ApiManagement.AccessInformationContracts.update", + "azure.mgmt.apimanagement.aio.operations.TenantAccessOperations.update": "Microsoft.ApiManagement.AccessInformationContracts.update", + "azure.mgmt.apimanagement.operations.TenantAccessOperations.list_by_service": "Microsoft.ApiManagement.AccessInformationContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.TenantAccessOperations.list_by_service": "Microsoft.ApiManagement.AccessInformationContracts.listByService", + "azure.mgmt.apimanagement.operations.TenantAccessOperations.regenerate_primary_key": "Microsoft.ApiManagement.AccessInformationContracts.regeneratePrimaryKey", + "azure.mgmt.apimanagement.aio.operations.TenantAccessOperations.regenerate_primary_key": "Microsoft.ApiManagement.AccessInformationContracts.regeneratePrimaryKey", + "azure.mgmt.apimanagement.operations.TenantAccessOperations.regenerate_secondary_key": "Microsoft.ApiManagement.AccessInformationContracts.regenerateSecondaryKey", + "azure.mgmt.apimanagement.aio.operations.TenantAccessOperations.regenerate_secondary_key": "Microsoft.ApiManagement.AccessInformationContracts.regenerateSecondaryKey", + "azure.mgmt.apimanagement.operations.TenantAccessOperations.list_secrets": "Microsoft.ApiManagement.AccessInformationContracts.listSecrets", + "azure.mgmt.apimanagement.aio.operations.TenantAccessOperations.list_secrets": "Microsoft.ApiManagement.AccessInformationContracts.listSecrets", + "azure.mgmt.apimanagement.operations.TenantAccessGitOperations.regenerate_primary_key": "Microsoft.ApiManagement.AccessInformationContracts.tenantAccessGitRegeneratePrimaryKey", + "azure.mgmt.apimanagement.aio.operations.TenantAccessGitOperations.regenerate_primary_key": "Microsoft.ApiManagement.AccessInformationContracts.tenantAccessGitRegeneratePrimaryKey", + "azure.mgmt.apimanagement.operations.TenantAccessGitOperations.regenerate_secondary_key": "Microsoft.ApiManagement.AccessInformationContracts.tenantAccessGitRegenerateSecondaryKey", + "azure.mgmt.apimanagement.aio.operations.TenantAccessGitOperations.regenerate_secondary_key": "Microsoft.ApiManagement.AccessInformationContracts.tenantAccessGitRegenerateSecondaryKey", + "azure.mgmt.apimanagement.operations.TenantConfigurationOperations.begin_deploy": "Microsoft.ApiManagement.AccessInformationContracts.deploy", + "azure.mgmt.apimanagement.aio.operations.TenantConfigurationOperations.begin_deploy": "Microsoft.ApiManagement.AccessInformationContracts.deploy", + "azure.mgmt.apimanagement.operations.TenantConfigurationOperations.begin_save": "Microsoft.ApiManagement.AccessInformationContracts.save", + "azure.mgmt.apimanagement.aio.operations.TenantConfigurationOperations.begin_save": "Microsoft.ApiManagement.AccessInformationContracts.save", + "azure.mgmt.apimanagement.operations.TenantConfigurationOperations.begin_validate": "Microsoft.ApiManagement.AccessInformationContracts.validate", + "azure.mgmt.apimanagement.aio.operations.TenantConfigurationOperations.begin_validate": "Microsoft.ApiManagement.AccessInformationContracts.validate", + "azure.mgmt.apimanagement.operations.TenantConfigurationOperations.get_sync_state": "Microsoft.ApiManagement.AccessInformationContracts.getSyncState", + "azure.mgmt.apimanagement.aio.operations.TenantConfigurationOperations.get_sync_state": "Microsoft.ApiManagement.AccessInformationContracts.getSyncState", + "azure.mgmt.apimanagement.operations.UserOperations.get": "Microsoft.ApiManagement.UserContracts.get", + "azure.mgmt.apimanagement.aio.operations.UserOperations.get": "Microsoft.ApiManagement.UserContracts.get", + "azure.mgmt.apimanagement.operations.UserOperations.get_entity_tag": "Microsoft.ApiManagement.UserContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.UserOperations.get_entity_tag": "Microsoft.ApiManagement.UserContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.UserOperations.create_or_update": "Microsoft.ApiManagement.UserContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.UserOperations.create_or_update": "Microsoft.ApiManagement.UserContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.UserOperations.update": "Microsoft.ApiManagement.UserContracts.update", + "azure.mgmt.apimanagement.aio.operations.UserOperations.update": "Microsoft.ApiManagement.UserContracts.update", + "azure.mgmt.apimanagement.operations.UserOperations.begin_delete": "Microsoft.ApiManagement.UserContracts.delete", + "azure.mgmt.apimanagement.aio.operations.UserOperations.begin_delete": "Microsoft.ApiManagement.UserContracts.delete", + "azure.mgmt.apimanagement.operations.UserOperations.list_by_service": "Microsoft.ApiManagement.UserContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.UserOperations.list_by_service": "Microsoft.ApiManagement.UserContracts.listByService", + "azure.mgmt.apimanagement.operations.UserOperations.generate_sso_url": "Microsoft.ApiManagement.UserContracts.generateSsoUrl", + "azure.mgmt.apimanagement.aio.operations.UserOperations.generate_sso_url": "Microsoft.ApiManagement.UserContracts.generateSsoUrl", + "azure.mgmt.apimanagement.operations.UserOperations.get_shared_access_token": "Microsoft.ApiManagement.UserContracts.getSharedAccessToken", + "azure.mgmt.apimanagement.aio.operations.UserOperations.get_shared_access_token": "Microsoft.ApiManagement.UserContracts.getSharedAccessToken", + "azure.mgmt.apimanagement.operations.UserGroupOperations.list": "Microsoft.ApiManagement.UserContracts.list", + "azure.mgmt.apimanagement.aio.operations.UserGroupOperations.list": "Microsoft.ApiManagement.UserContracts.list", + "azure.mgmt.apimanagement.operations.UserIdentitiesOperations.list": "Microsoft.ApiManagement.UserContracts.userIdentitiesList", + "azure.mgmt.apimanagement.aio.operations.UserIdentitiesOperations.list": "Microsoft.ApiManagement.UserContracts.userIdentitiesList", + "azure.mgmt.apimanagement.operations.UserConfirmationPasswordOperations.send": "Microsoft.ApiManagement.UserContracts.send", + "azure.mgmt.apimanagement.aio.operations.UserConfirmationPasswordOperations.send": "Microsoft.ApiManagement.UserContracts.send", + "azure.mgmt.apimanagement.operations.ApiManagementWorkspaceLinkOperations.get": "Microsoft.ApiManagement.ApiManagementWorkspaceLinksResources.get", + "azure.mgmt.apimanagement.aio.operations.ApiManagementWorkspaceLinkOperations.get": "Microsoft.ApiManagement.ApiManagementWorkspaceLinksResources.get", + "azure.mgmt.apimanagement.operations.ApiManagementWorkspaceLinksOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementWorkspaceLinksResources.listByService", + "azure.mgmt.apimanagement.aio.operations.ApiManagementWorkspaceLinksOperations.list_by_service": "Microsoft.ApiManagement.ApiManagementWorkspaceLinksResources.listByService", + "azure.mgmt.apimanagement.operations.WorkspaceOperations.get": "Microsoft.ApiManagement.WorkspaceContracts.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceOperations.get": "Microsoft.ApiManagement.WorkspaceContracts.get", + "azure.mgmt.apimanagement.operations.WorkspaceOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceContracts.getEntityTag", + "azure.mgmt.apimanagement.aio.operations.WorkspaceOperations.get_entity_tag": "Microsoft.ApiManagement.WorkspaceContracts.getEntityTag", + "azure.mgmt.apimanagement.operations.WorkspaceOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceContracts.createOrUpdate", + "azure.mgmt.apimanagement.aio.operations.WorkspaceOperations.create_or_update": "Microsoft.ApiManagement.WorkspaceContracts.createOrUpdate", + "azure.mgmt.apimanagement.operations.WorkspaceOperations.update": "Microsoft.ApiManagement.WorkspaceContracts.update", + "azure.mgmt.apimanagement.aio.operations.WorkspaceOperations.update": "Microsoft.ApiManagement.WorkspaceContracts.update", + "azure.mgmt.apimanagement.operations.WorkspaceOperations.delete": "Microsoft.ApiManagement.WorkspaceContracts.delete", + "azure.mgmt.apimanagement.aio.operations.WorkspaceOperations.delete": "Microsoft.ApiManagement.WorkspaceContracts.delete", + "azure.mgmt.apimanagement.operations.WorkspaceOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceContracts.listByService", + "azure.mgmt.apimanagement.aio.operations.WorkspaceOperations.list_by_service": "Microsoft.ApiManagement.WorkspaceContracts.listByService", + "azure.mgmt.apimanagement.operations.ApiExportOperations.get": "Microsoft.ApiManagement.ApiExportOperationGroup.get", + "azure.mgmt.apimanagement.aio.operations.ApiExportOperations.get": "Microsoft.ApiManagement.ApiExportOperationGroup.get", + "azure.mgmt.apimanagement.operations.ApiManagementSkusOperations.list": "Microsoft.ApiManagement.ApiManagementSkusOperationGroup.list", + "azure.mgmt.apimanagement.aio.operations.ApiManagementSkusOperations.list": "Microsoft.ApiManagement.ApiManagementSkusOperationGroup.list", + "azure.mgmt.apimanagement.operations.WorkspaceApiExportOperations.get": "Microsoft.ApiManagement.WorkspaceApiExportOperationGroup.get", + "azure.mgmt.apimanagement.aio.operations.WorkspaceApiExportOperations.get": "Microsoft.ApiManagement.WorkspaceApiExportOperationGroup.get", + "azure.mgmt.apimanagement.operations.OperationStatusOperations.get": "Microsoft.ApiManagement.OperationStatusOperationGroup.get", + "azure.mgmt.apimanagement.aio.operations.OperationStatusOperations.get": "Microsoft.ApiManagement.OperationStatusOperationGroup.get", + "azure.mgmt.apimanagement.operations.OperationsResultsOperations.get": "Microsoft.ApiManagement.OperationsResultsOperationGroup.get", + "azure.mgmt.apimanagement.aio.operations.OperationsResultsOperations.get": "Microsoft.ApiManagement.OperationsResultsOperationGroup.get", + "azure.mgmt.apimanagement.ApiManagementClient.begin_perform_connectivity_check_async": "Microsoft.ApiManagement.ApiManagementServiceResources.performConnectivityCheckAsync", + "azure.mgmt.apimanagement.aio.ApiManagementClient.begin_perform_connectivity_check_async": "Microsoft.ApiManagement.ApiManagementServiceResources.performConnectivityCheckAsync" + } +} \ No newline at end of file diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/__init__.py index 8db66d3d0f0f..d55ccad1f573 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/__init__.py @@ -1 +1 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py index 84fc939c766a..a35a4a4310f4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._api_management_client import ApiManagementClient # type: ignore +from ._client import ApiManagementClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_client.py similarity index 93% rename from sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py rename to sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_client.py index 0954fe940a13..5e25ba7458a4 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_api_management_client.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_client.py @@ -2,32 +2,33 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints -from . import models as _models from ._configuration import ApiManagementClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( AllPoliciesOperations, ApiDiagnosticOperations, ApiExportOperations, ApiGatewayConfigConnectionOperations, + ApiGatewayHostnameBindingOperations, ApiGatewayOperations, ApiIssueAttachmentOperations, ApiIssueCommentOperations, ApiIssueOperations, - ApiManagementClientOperationsMixin, ApiManagementGatewaySkusOperations, ApiManagementOperationsOperations, ApiManagementServiceOperations, @@ -44,6 +45,7 @@ ApiRevisionOperations, ApiSchemaOperations, ApiTagDescriptionOperations, + ApiToolOperations, ApiVersionSetOperations, ApiWikiOperations, ApiWikisOperations, @@ -55,6 +57,8 @@ BackendOperations, CacheOperations, CertificateOperations, + ClientApplicationOperations, + ClientApplicationProductLinkOperations, ContentItemOperations, ContentTypeOperations, DelegationSettingsOperations, @@ -156,44 +160,176 @@ WorkspaceTagOperationLinkOperations, WorkspaceTagOperations, WorkspaceTagProductLinkOperations, + _ApiManagementClientOperationsMixin, ) if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential -class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes - """ApiManagement Client. +class ApiManagementClient(_ApiManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """Resource provider operation status. + :ivar workspace_api: WorkspaceApiOperations operations + :vartype workspace_api: azure.mgmt.apimanagement.operations.WorkspaceApiOperations + :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 graph_ql_api_resolver_policy: GraphQLApiResolverPolicyOperations operations + :vartype graph_ql_api_resolver_policy: + azure.mgmt.apimanagement.operations.GraphQLApiResolverPolicyOperations + :ivar api_policy: ApiPolicyOperations operations + :vartype api_policy: azure.mgmt.apimanagement.operations.ApiPolicyOperations + :ivar policy: PolicyOperations operations + :vartype policy: azure.mgmt.apimanagement.operations.PolicyOperations + :ivar product_policy: ProductPolicyOperations operations + :vartype product_policy: azure.mgmt.apimanagement.operations.ProductPolicyOperations + :ivar workspace_policy: WorkspacePolicyOperations operations + :vartype workspace_policy: azure.mgmt.apimanagement.operations.WorkspacePolicyOperations + :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_product_policy: WorkspaceProductPolicyOperations operations + :vartype workspace_product_policy: + azure.mgmt.apimanagement.operations.WorkspaceProductPolicyOperations + :ivar tag: TagOperations operations + :vartype tag: azure.mgmt.apimanagement.operations.TagOperations + :ivar workspace_tag: WorkspaceTagOperations operations + :vartype workspace_tag: azure.mgmt.apimanagement.operations.WorkspaceTagOperations + :ivar workspace_api_schema: WorkspaceApiSchemaOperations operations + :vartype workspace_api_schema: azure.mgmt.apimanagement.operations.WorkspaceApiSchemaOperations + :ivar diagnostic: DiagnosticOperations operations + :vartype diagnostic: azure.mgmt.apimanagement.operations.DiagnosticOperations + :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 issue: IssueOperations operations + :vartype issue: azure.mgmt.apimanagement.operations.IssueOperations + :ivar product_wiki: ProductWikiOperations operations + :vartype product_wiki: azure.mgmt.apimanagement.operations.ProductWikiOperations + :ivar workspace_api_version_set: WorkspaceApiVersionSetOperations operations + :vartype workspace_api_version_set: + azure.mgmt.apimanagement.operations.WorkspaceApiVersionSetOperations + :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_group: WorkspaceGroupOperations operations + :vartype workspace_group: azure.mgmt.apimanagement.operations.WorkspaceGroupOperations + :ivar workspace_logger: WorkspaceLoggerOperations operations + :vartype workspace_logger: azure.mgmt.apimanagement.operations.WorkspaceLoggerOperations + :ivar workspace_named_value: WorkspaceNamedValueOperations operations + :vartype workspace_named_value: + azure.mgmt.apimanagement.operations.WorkspaceNamedValueOperations + :ivar workspace_notification: WorkspaceNotificationOperations operations + :vartype workspace_notification: + azure.mgmt.apimanagement.operations.WorkspaceNotificationOperations + :ivar workspace_policy_fragment: WorkspacePolicyFragmentOperations operations + :vartype workspace_policy_fragment: + azure.mgmt.apimanagement.operations.WorkspacePolicyFragmentOperations + :ivar sign_in_settings: SignInSettingsOperations operations + :vartype sign_in_settings: azure.mgmt.apimanagement.operations.SignInSettingsOperations + :ivar sign_up_settings: SignUpSettingsOperations operations + :vartype sign_up_settings: azure.mgmt.apimanagement.operations.SignUpSettingsOperations + :ivar delegation_settings: DelegationSettingsOperations operations + :vartype delegation_settings: azure.mgmt.apimanagement.operations.DelegationSettingsOperations + :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_global_schema: WorkspaceGlobalSchemaOperations operations + :vartype workspace_global_schema: + azure.mgmt.apimanagement.operations.WorkspaceGlobalSchemaOperations + :ivar user_subscription: UserSubscriptionOperations operations + :vartype user_subscription: azure.mgmt.apimanagement.operations.UserSubscriptionOperations + :ivar workspace_subscription: WorkspaceSubscriptionOperations operations + :vartype workspace_subscription: + azure.mgmt.apimanagement.operations.WorkspaceSubscriptionOperations + :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 api_management_operations: ApiManagementOperationsOperations operations + :vartype api_management_operations: + azure.mgmt.apimanagement.operations.ApiManagementOperationsOperations :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 all_policies: AllPoliciesOperations operations - :vartype all_policies: azure.mgmt.apimanagement.operations.AllPoliciesOperations :ivar api: ApiOperations operations :vartype api: azure.mgmt.apimanagement.operations.ApiOperations :ivar api_revision: ApiRevisionOperations operations :vartype api_revision: azure.mgmt.apimanagement.operations.ApiRevisionOperations + :ivar api_product: ApiProductOperations operations + :vartype api_product: azure.mgmt.apimanagement.operations.ApiProductOperations + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.apimanagement.operations.OperationOperations + :ivar workspace_api_revision: WorkspaceApiRevisionOperations operations + :vartype workspace_api_revision: + azure.mgmt.apimanagement.operations.WorkspaceApiRevisionOperations + :ivar api_management_service: ApiManagementServiceOperations operations + :vartype api_management_service: + azure.mgmt.apimanagement.operations.ApiManagementServiceOperations + :ivar all_policies: AllPoliciesOperations operations + :vartype all_policies: azure.mgmt.apimanagement.operations.AllPoliciesOperations + :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations + :vartype api_management_service_skus: + azure.mgmt.apimanagement.operations.ApiManagementServiceSkusOperations + :ivar network_status: NetworkStatusOperations operations + :vartype network_status: azure.mgmt.apimanagement.operations.NetworkStatusOperations + :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations + operations + :vartype outbound_network_dependencies_endpoints: + azure.mgmt.apimanagement.operations.OutboundNetworkDependenciesEndpointsOperations + :ivar policy_description: PolicyDescriptionOperations operations + :vartype policy_description: azure.mgmt.apimanagement.operations.PolicyDescriptionOperations + :ivar policy_restriction_validations: PolicyRestrictionValidationsOperations operations + :vartype policy_restriction_validations: + azure.mgmt.apimanagement.operations.PolicyRestrictionValidationsOperations + :ivar portal_settings: PortalSettingsOperations operations + :vartype portal_settings: azure.mgmt.apimanagement.operations.PortalSettingsOperations + :ivar product: ProductOperations operations + :vartype product: azure.mgmt.apimanagement.operations.ProductOperations + :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations + :vartype quota_by_counter_keys: + azure.mgmt.apimanagement.operations.QuotaByCounterKeysOperations + :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations + :vartype quota_by_period_keys: azure.mgmt.apimanagement.operations.QuotaByPeriodKeysOperations + :ivar region: RegionOperations operations + :vartype region: azure.mgmt.apimanagement.operations.RegionOperations + :ivar reports: ReportsOperations operations + :vartype reports: azure.mgmt.apimanagement.operations.ReportsOperations + :ivar tag_resource: TagResourceOperations operations + :vartype tag_resource: azure.mgmt.apimanagement.operations.TagResourceOperations :ivar api_release: ApiReleaseOperations operations :vartype api_release: azure.mgmt.apimanagement.operations.ApiReleaseOperations :ivar api_operation: ApiOperationOperations operations :vartype api_operation: azure.mgmt.apimanagement.operations.ApiOperationOperations :ivar api_operation_policy: ApiOperationPolicyOperations operations :vartype api_operation_policy: azure.mgmt.apimanagement.operations.ApiOperationPolicyOperations - :ivar tag: TagOperations operations - :vartype tag: azure.mgmt.apimanagement.operations.TagOperations :ivar graph_ql_api_resolver: GraphQLApiResolverOperations operations :vartype graph_ql_api_resolver: azure.mgmt.apimanagement.operations.GraphQLApiResolverOperations - :ivar graph_ql_api_resolver_policy: GraphQLApiResolverPolicyOperations operations - :vartype graph_ql_api_resolver_policy: - azure.mgmt.apimanagement.operations.GraphQLApiResolverPolicyOperations - :ivar api_product: ApiProductOperations operations - :vartype api_product: azure.mgmt.apimanagement.operations.ApiProductOperations - :ivar api_policy: ApiPolicyOperations operations - :vartype api_policy: azure.mgmt.apimanagement.operations.ApiPolicyOperations :ivar api_schema: ApiSchemaOperations operations :vartype api_schema: azure.mgmt.apimanagement.operations.ApiSchemaOperations :ivar api_diagnostic: ApiDiagnosticOperations operations @@ -206,14 +342,14 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :vartype api_issue_attachment: azure.mgmt.apimanagement.operations.ApiIssueAttachmentOperations :ivar api_tag_description: ApiTagDescriptionOperations operations :vartype api_tag_description: azure.mgmt.apimanagement.operations.ApiTagDescriptionOperations - :ivar operation: OperationOperations operations - :vartype operation: azure.mgmt.apimanagement.operations.OperationOperations :ivar api_wiki: ApiWikiOperations operations :vartype api_wiki: azure.mgmt.apimanagement.operations.ApiWikiOperations :ivar api_wikis: ApiWikisOperations operations :vartype api_wikis: azure.mgmt.apimanagement.operations.ApiWikisOperations - :ivar api_export: ApiExportOperations operations - :vartype api_export: azure.mgmt.apimanagement.operations.ApiExportOperations + :ivar product_wikis: ProductWikisOperations operations + :vartype product_wikis: azure.mgmt.apimanagement.operations.ProductWikisOperations + :ivar api_tool: ApiToolOperations operations + :vartype api_tool: azure.mgmt.apimanagement.operations.ApiToolOperations :ivar api_version_set: ApiVersionSetOperations operations :vartype api_version_set: azure.mgmt.apimanagement.operations.ApiVersionSetOperations :ivar authorization_provider: AuthorizationProviderOperations operations @@ -242,17 +378,6 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :vartype content_item: azure.mgmt.apimanagement.operations.ContentItemOperations :ivar deleted_services: DeletedServicesOperations operations :vartype deleted_services: azure.mgmt.apimanagement.operations.DeletedServicesOperations - :ivar api_management_operations: ApiManagementOperationsOperations operations - :vartype api_management_operations: - azure.mgmt.apimanagement.operations.ApiManagementOperationsOperations - :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations - :vartype api_management_service_skus: - azure.mgmt.apimanagement.operations.ApiManagementServiceSkusOperations - :ivar api_management_service: ApiManagementServiceOperations operations - :vartype api_management_service: - 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 @@ -260,13 +385,16 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :ivar api_gateway_config_connection: ApiGatewayConfigConnectionOperations operations :vartype api_gateway_config_connection: azure.mgmt.apimanagement.operations.ApiGatewayConfigConnectionOperations + :ivar api_gateway_hostname_binding: ApiGatewayHostnameBindingOperations operations + :vartype api_gateway_hostname_binding: + azure.mgmt.apimanagement.operations.ApiGatewayHostnameBindingOperations :ivar gateway: GatewayOperations operations :vartype gateway: azure.mgmt.apimanagement.operations.GatewayOperations + :ivar gateway_api: GatewayApiOperations operations + :vartype gateway_api: azure.mgmt.apimanagement.operations.GatewayApiOperations :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations :vartype gateway_hostname_configuration: azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations - :ivar gateway_api: GatewayApiOperations operations - :vartype gateway_api: azure.mgmt.apimanagement.operations.GatewayApiOperations :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations :vartype gateway_certificate_authority: azure.mgmt.apimanagement.operations.GatewayCertificateAuthorityOperations @@ -274,16 +402,14 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :vartype group: azure.mgmt.apimanagement.operations.GroupOperations :ivar group_user: GroupUserOperations operations :vartype group_user: azure.mgmt.apimanagement.operations.GroupUserOperations + :ivar workspace_group_user: WorkspaceGroupUserOperations operations + :vartype workspace_group_user: azure.mgmt.apimanagement.operations.WorkspaceGroupUserOperations :ivar identity_provider: IdentityProviderOperations operations :vartype identity_provider: azure.mgmt.apimanagement.operations.IdentityProviderOperations - :ivar issue: IssueOperations operations - :vartype issue: azure.mgmt.apimanagement.operations.IssueOperations :ivar logger: LoggerOperations operations :vartype logger: azure.mgmt.apimanagement.operations.LoggerOperations :ivar named_value: NamedValueOperations operations :vartype named_value: azure.mgmt.apimanagement.operations.NamedValueOperations - :ivar network_status: NetworkStatusOperations operations - :vartype network_status: azure.mgmt.apimanagement.operations.NetworkStatusOperations :ivar notification: NotificationOperations operations :vartype notification: azure.mgmt.apimanagement.operations.NotificationOperations :ivar notification_recipient_user: NotificationRecipientUserOperations operations @@ -292,41 +418,33 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :ivar notification_recipient_email: NotificationRecipientEmailOperations operations :vartype notification_recipient_email: azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations + :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 open_id_connect_provider: OpenIdConnectProviderOperations operations :vartype open_id_connect_provider: azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations - :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations - operations - :vartype outbound_network_dependencies_endpoints: - azure.mgmt.apimanagement.operations.OutboundNetworkDependenciesEndpointsOperations - :ivar policy: PolicyOperations operations - :vartype policy: azure.mgmt.apimanagement.operations.PolicyOperations - :ivar policy_description: PolicyDescriptionOperations operations - :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 client_application: ClientApplicationOperations operations + :vartype client_application: azure.mgmt.apimanagement.operations.ClientApplicationOperations + :ivar client_application_product_link: ClientApplicationProductLinkOperations operations + :vartype client_application_product_link: + azure.mgmt.apimanagement.operations.ClientApplicationProductLinkOperations :ivar portal_revision: PortalRevisionOperations operations :vartype portal_revision: azure.mgmt.apimanagement.operations.PortalRevisionOperations - :ivar portal_settings: PortalSettingsOperations operations - :vartype portal_settings: azure.mgmt.apimanagement.operations.PortalSettingsOperations - :ivar sign_in_settings: SignInSettingsOperations operations - :vartype sign_in_settings: azure.mgmt.apimanagement.operations.SignInSettingsOperations - :ivar sign_up_settings: SignUpSettingsOperations operations - :vartype sign_up_settings: azure.mgmt.apimanagement.operations.SignUpSettingsOperations - :ivar delegation_settings: DelegationSettingsOperations operations - :vartype delegation_settings: azure.mgmt.apimanagement.operations.DelegationSettingsOperations :ivar private_endpoint_connection: PrivateEndpointConnectionOperations operations :vartype private_endpoint_connection: azure.mgmt.apimanagement.operations.PrivateEndpointConnectionOperations - :ivar product: ProductOperations operations - :vartype product: azure.mgmt.apimanagement.operations.ProductOperations :ivar product_api: ProductApiOperations operations :vartype product_api: azure.mgmt.apimanagement.operations.ProductApiOperations :ivar product_group: ProductGroupOperations operations @@ -334,35 +452,16 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :ivar product_subscriptions: ProductSubscriptionsOperations operations :vartype product_subscriptions: azure.mgmt.apimanagement.operations.ProductSubscriptionsOperations - :ivar product_policy: ProductPolicyOperations operations - :vartype product_policy: azure.mgmt.apimanagement.operations.ProductPolicyOperations - :ivar product_wiki: ProductWikiOperations operations - :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 - :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations - :vartype quota_by_period_keys: azure.mgmt.apimanagement.operations.QuotaByPeriodKeysOperations - :ivar region: RegionOperations operations - :vartype region: azure.mgmt.apimanagement.operations.RegionOperations - :ivar reports: ReportsOperations operations - :vartype reports: azure.mgmt.apimanagement.operations.ReportsOperations :ivar global_schema: GlobalSchemaOperations operations :vartype global_schema: azure.mgmt.apimanagement.operations.GlobalSchemaOperations :ivar tenant_settings: TenantSettingsOperations operations :vartype tenant_settings: azure.mgmt.apimanagement.operations.TenantSettingsOperations - :ivar api_management_skus: ApiManagementSkusOperations operations - :vartype api_management_skus: azure.mgmt.apimanagement.operations.ApiManagementSkusOperations :ivar subscription: SubscriptionOperations operations :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 @@ -380,120 +479,41 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :vartype user: azure.mgmt.apimanagement.operations.UserOperations :ivar user_group: UserGroupOperations operations :vartype user_group: azure.mgmt.apimanagement.operations.UserGroupOperations - :ivar user_subscription: UserSubscriptionOperations operations - :vartype user_subscription: azure.mgmt.apimanagement.operations.UserSubscriptionOperations :ivar user_identities: UserIdentitiesOperations operations :vartype user_identities: azure.mgmt.apimanagement.operations.UserIdentitiesOperations :ivar user_confirmation_password: UserConfirmationPasswordOperations operations :vartype user_confirmation_password: azure.mgmt.apimanagement.operations.UserConfirmationPasswordOperations - :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 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_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 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 api_export: ApiExportOperations operations + :vartype api_export: azure.mgmt.apimanagement.operations.ApiExportOperations + :ivar api_management_skus: ApiManagementSkusOperations operations + :vartype api_management_skus: azure.mgmt.apimanagement.operations.ApiManagementSkusOperations :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. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :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". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-03-01-preview". Default value is "2025-03-01-preview". 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 Retry-After header is present. @@ -503,12 +523,26 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = ApiManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -527,151 +561,137 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.api_gateway = ApiGatewayOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_management_gateway_skus = ApiManagementGatewaySkusOperations( + self.workspace_api = WorkspaceApiOperations(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.graph_ql_api_resolver_policy = GraphQLApiResolverPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_policy = ApiPolicyOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_policy = ProductPolicyOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_policy = WorkspacePolicyOperations( self._client, self._config, self._serialize, self._deserialize ) - self.all_policies = AllPoliciesOperations(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) - self.api_operation = ApiOperationOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_operation_policy = ApiOperationPolicyOperations( + 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_product_policy = WorkspaceProductPolicyOperations( self._client, self._config, self._serialize, self._deserialize ) self.tag = TagOperations(self._client, self._config, self._serialize, self._deserialize) - self.graph_ql_api_resolver = GraphQLApiResolverOperations( + self.workspace_tag = WorkspaceTagOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_api_schema = WorkspaceApiSchemaOperations( self._client, self._config, self._serialize, self._deserialize ) - self.graph_ql_api_resolver_policy = GraphQLApiResolverPolicyOperations( + self.diagnostic = DiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_diagnostic = WorkspaceDiagnosticOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_product = ApiProductOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_policy = ApiPolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_schema = ApiSchemaOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_diagnostic = ApiDiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_issue = ApiIssueOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_issue_comment = ApiIssueCommentOperations( + self.workspace_api_diagnostic = WorkspaceApiDiagnosticOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_issue_attachment = ApiIssueAttachmentOperations( + self.issue = IssueOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_wiki = ProductWikiOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_api_version_set = WorkspaceApiVersionSetOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_tag_description = ApiTagDescriptionOperations( + self.workspace_backend = WorkspaceBackendOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_wiki = ApiWikiOperations(self._client, self._config, self._serialize, self._deserialize) - 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_provider = AuthorizationProviderOperations( + self.workspace_certificate = WorkspaceCertificateOperations( self._client, self._config, self._serialize, self._deserialize ) - self.authorization = AuthorizationOperations(self._client, self._config, self._serialize, self._deserialize) - self.authorization_login_links = AuthorizationLoginLinksOperations( + self.workspace_group = WorkspaceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_logger = WorkspaceLoggerOperations( self._client, self._config, self._serialize, self._deserialize ) - self.authorization_access_policy = AuthorizationAccessPolicyOperations( + self.workspace_named_value = WorkspaceNamedValueOperations( self._client, self._config, self._serialize, self._deserialize ) - self.authorization_server = AuthorizationServerOperations( + self.workspace_notification = WorkspaceNotificationOperations( 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) - self.content_type = ContentTypeOperations(self._client, self._config, self._serialize, self._deserialize) - self.content_item = ContentItemOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_services = DeletedServicesOperations( + self.workspace_policy_fragment = WorkspacePolicyFragmentOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_operations = ApiManagementOperationsOperations( + self.sign_in_settings = SignInSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sign_up_settings = SignUpSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.delegation_settings = DelegationSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_service_skus = ApiManagementServiceSkusOperations( + self.workspace_product = WorkspaceProductOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_service = ApiManagementServiceOperations( + self.workspace_product_api_link = WorkspaceProductApiLinkOperations( 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.api_gateway_config_connection = ApiGatewayConfigConnectionOperations( + self.workspace_product_group_link = WorkspaceProductGroupLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.gateway = GatewayOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations( + self.workspace_global_schema = WorkspaceGlobalSchemaOperations( self._client, self._config, self._serialize, self._deserialize ) - self.gateway_api = GatewayApiOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_certificate_authority = GatewayCertificateAuthorityOperations( + self.user_subscription = UserSubscriptionOperations( 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( + self.workspace_subscription = WorkspaceSubscriptionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.issue = IssueOperations(self._client, self._config, self._serialize, self._deserialize) - self.logger = LoggerOperations(self._client, self._config, self._serialize, self._deserialize) - self.named_value = NamedValueOperations(self._client, self._config, self._serialize, self._deserialize) - self.network_status = NetworkStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.notification = NotificationOperations(self._client, self._config, self._serialize, self._deserialize) - self.notification_recipient_user = NotificationRecipientUserOperations( + self.workspace_tag_api_link = WorkspaceTagApiLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.notification_recipient_email = NotificationRecipientEmailOperations( + self.workspace_tag_operation_link = WorkspaceTagOperationLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.open_id_connect_provider = OpenIdConnectProviderOperations( + self.workspace_tag_product_link = WorkspaceTagProductLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.outbound_network_dependencies_endpoints = OutboundNetworkDependenciesEndpointsOperations( + self.api_management_operations = ApiManagementOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_description = PolicyDescriptionOperations( + 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.policy_fragment = PolicyFragmentOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_restriction = PolicyRestrictionOperations( + 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_product = ApiProductOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_api_revision = WorkspaceApiRevisionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_restriction_validations = PolicyRestrictionValidationsOperations( + self.api_management_service = ApiManagementServiceOperations( 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) - self.sign_in_settings = SignInSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sign_up_settings = SignUpSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.delegation_settings = DelegationSettingsOperations( + self.all_policies = AllPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_management_service_skus = ApiManagementServiceSkusOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_endpoint_connection = PrivateEndpointConnectionOperations( + self.network_status = NetworkStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.outbound_network_dependencies_endpoints = OutboundNetworkDependenciesEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.product = ProductOperations(self._client, self._config, self._serialize, self._deserialize) - self.product_api = ProductApiOperations(self._client, self._config, self._serialize, self._deserialize) - self.product_group = ProductGroupOperations(self._client, self._config, self._serialize, self._deserialize) - self.product_subscriptions = ProductSubscriptionsOperations( + self.policy_description = PolicyDescriptionOperations( self._client, self._config, self._serialize, self._deserialize ) - 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.policy_restriction_validations = PolicyRestrictionValidationsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.portal_settings = PortalSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.product = ProductOperations(self._client, self._config, self._serialize, self._deserialize) self.quota_by_counter_keys = QuotaByCounterKeysOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -680,126 +700,149 @@ def __init__( ) self.region = RegionOperations(self._client, self._config, self._serialize, self._deserialize) self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) - self.global_schema = GlobalSchemaOperations(self._client, self._config, self._serialize, self._deserialize) - self.tenant_settings = TenantSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_management_skus = ApiManagementSkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) - 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.api_release = ApiReleaseOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_operation = ApiOperationOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_operation_policy = ApiOperationPolicyOperations( self._client, self._config, self._serialize, self._deserialize ) - self.tenant_configuration = TenantConfigurationOperations( + self.graph_ql_api_resolver = GraphQLApiResolverOperations( self._client, self._config, self._serialize, self._deserialize ) - self.user = UserOperations(self._client, self._config, self._serialize, self._deserialize) - self.user_group = UserGroupOperations(self._client, self._config, self._serialize, self._deserialize) - self.user_subscription = UserSubscriptionOperations( + self.api_schema = ApiSchemaOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_diagnostic = ApiDiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_issue = ApiIssueOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_issue_comment = ApiIssueCommentOperations( self._client, self._config, self._serialize, self._deserialize ) - self.user_identities = UserIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) - self.user_confirmation_password = UserConfirmationPasswordOperations( + self.api_issue_attachment = ApiIssueAttachmentOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_backend = WorkspaceBackendOperations( + self.api_tag_description = ApiTagDescriptionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_certificate = WorkspaceCertificateOperations( + self.api_wiki = ApiWikiOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_wikis = ApiWikisOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_wikis = ProductWikisOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_tool = ApiToolOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_version_set = ApiVersionSetOperations(self._client, self._config, self._serialize, self._deserialize) + self.authorization_provider = AuthorizationProviderOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_diagnostic = WorkspaceDiagnosticOperations( + self.authorization = AuthorizationOperations(self._client, self._config, self._serialize, self._deserialize) + self.authorization_login_links = AuthorizationLoginLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_diagnostic = WorkspaceApiDiagnosticOperations( + self.authorization_access_policy = AuthorizationAccessPolicyOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_workspace_links = ApiManagementWorkspaceLinksOperations( + self.authorization_server = AuthorizationServerOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_workspace_link = ApiManagementWorkspaceLinkOperations( + 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) + self.content_type = ContentTypeOperations(self._client, self._config, self._serialize, self._deserialize) + self.content_item = ContentItemOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_services = DeletedServicesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_logger = WorkspaceLoggerOperations( + self.documentation = DocumentationOperations(self._client, self._config, self._serialize, self._deserialize) + self.email_template = EmailTemplateOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_gateway_config_connection = ApiGatewayConfigConnectionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace = WorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_policy = WorkspacePolicyOperations( + self.api_gateway_hostname_binding = ApiGatewayHostnameBindingOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_named_value = WorkspaceNamedValueOperations( + self.gateway = GatewayOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_api = GatewayApiOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_global_schema = WorkspaceGlobalSchemaOperations( + self.gateway_certificate_authority = GatewayCertificateAuthorityOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_notification = WorkspaceNotificationOperations( + self.group = GroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.group_user = GroupUserOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_group_user = WorkspaceGroupUserOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_notification_recipient_user = WorkspaceNotificationRecipientUserOperations( + self.identity_provider = IdentityProviderOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_notification_recipient_email = WorkspaceNotificationRecipientEmailOperations( + self.logger = LoggerOperations(self._client, self._config, self._serialize, self._deserialize) + self.named_value = NamedValueOperations(self._client, self._config, self._serialize, self._deserialize) + self.notification = NotificationOperations(self._client, self._config, self._serialize, self._deserialize) + self.notification_recipient_user = NotificationRecipientUserOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_policy_fragment = WorkspacePolicyFragmentOperations( + self.notification_recipient_email = NotificationRecipientEmailOperations( 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.workspace_notification_recipient_user = WorkspaceNotificationRecipientUserOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_subscription = WorkspaceSubscriptionOperations( + self.workspace_notification_recipient_email = WorkspaceNotificationRecipientEmailOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_version_set = WorkspaceApiVersionSetOperations( + self.open_id_connect_provider = OpenIdConnectProviderOperations( 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.policy_fragment = PolicyFragmentOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_restriction = PolicyRestrictionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_release = WorkspaceApiReleaseOperations( + self.portal_config = PortalConfigOperations(self._client, self._config, self._serialize, self._deserialize) + self.client_application = ClientApplicationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_operation = WorkspaceApiOperationOperations( + self.client_application_product_link = ClientApplicationProductLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_operation_policy = WorkspaceApiOperationPolicyOperations( + self.portal_revision = PortalRevisionOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connection = PrivateEndpointConnectionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_policy = WorkspaceApiPolicyOperations( + self.product_api = ProductApiOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_group = ProductGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_subscriptions = ProductSubscriptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_schema = WorkspaceApiSchemaOperations( + 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.workspace_product = WorkspaceProductOperations( + self.global_schema = GlobalSchemaOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_settings = TenantSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations(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.workspace_product_api_link = WorkspaceProductApiLinkOperations( + 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 ) - self.workspace_product_group_link = WorkspaceProductGroupLinkOperations( + self.tenant_configuration = TenantConfigurationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_product_policy = WorkspaceProductPolicyOperations( + self.user = UserOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_group = UserGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_identities = UserIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_confirmation_password = UserConfirmationPasswordOperations( 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.api_management_workspace_link = ApiManagementWorkspaceLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_tag_operation_link = WorkspaceTagOperationLinkOperations( + self.api_management_workspace_links = ApiManagementWorkspaceLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_tag_product_link = WorkspaceTagProductLinkOperations( + self.workspace = WorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_export = ApiExportOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_management_skus = ApiManagementSkusOperations( self._client, self._config, self._serialize, self._deserialize ) self.workspace_api_export = WorkspaceApiExportOperations( @@ -812,13 +855,13 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -831,7 +874,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: 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 9a0a60b29f72..5cead5f882b9 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -14,6 +14,7 @@ from ._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials import TokenCredential @@ -23,17 +24,30 @@ class ApiManagementClientConfiguration: # pylint: disable=too-many-instance-att Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential :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 "2024-05-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-03-01-preview". Default value is "2025-03-01-preview". 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", "2024-05-01") + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2025-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -42,6 +56,8 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-apimanagement/{}".format(VERSION)) 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 17dbc073e01b..87676c65a8f0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_patch.py @@ -1,32 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# 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(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/__init__.py new file mode 100644 index 000000000000..8026245c2abc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/model_base.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/model_base.py new file mode 100644 index 000000000000..a75a22adbb97 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/model_base.py @@ -0,0 +1,1368 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null +from azure.core.rest import HttpResponse + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._backcompat_attr_to_rest_field: dict[str, _RestField] = { + Model._get_backcompat_attribute_name(cls._attr_to_rest_field, attr): rf + for attr, rf in cls._attr_to_rest_field.items() + } + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_backcompat_attribute_name(cls, attr_to_rest_field: dict[str, "_RestField"], attr_name: str) -> str: + rest_field_obj = attr_to_rest_field.get(attr_name) # pylint: disable=protected-access + if rest_field_obj is None: + return attr_name + original_tsp_name = getattr(rest_field_obj, "_original_tsp_name", None) # pylint: disable=protected-access + if original_tsp_name: + return original_tsp_name + return attr_name + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value.text if isinstance(value, ET.Element) else value) + except ValueError: + # for unknown value, return raw value + return value.text if isinstance(value, ET.Element) else value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + original_tsp_name: typing.Optional[str] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._is_optional = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + self._original_tsp_name = original_tsp_name + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + original_tsp_name: typing.Optional[str] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + original_tsp_name=original_tsp_name, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/serialization.py similarity index 92% rename from sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py rename to sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/serialization.py index b24ab2885450..81ec1de5922b 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_serialization.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/serialization.py @@ -1,28 +1,10 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pyright: reportUnnecessaryTypeIgnoreComment=false @@ -39,7 +21,6 @@ import sys import codecs from typing import ( - Dict, Any, cast, Optional, @@ -48,10 +29,7 @@ IO, Mapping, Callable, - TypeVar, MutableMapping, - Type, - List, ) try: @@ -61,13 +39,13 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -ModelType = TypeVar("ModelType", bound="Model") JSON = MutableMapping[str, Any] @@ -185,73 +163,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset) -> None: - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} + self.additional_properties: Optional[dict[str, Any]] = {} for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -397,7 +309,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: def as_dict( self, keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + key_transformer: Callable[[str, dict[str, Any], Any], Any] = attribute_transformer, **kwargs: Any ) -> JSON: """Return a dict that can be serialized using json.dump. @@ -450,25 +362,25 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( - cls: Type[ModelType], + cls, data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + key_extractors: Optional[Callable[[str, dict[str, Any], Any], Any]] = None, content_type: Optional[str] = None, - ) -> ModelType: + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -479,8 +391,8 @@ def from_dict( :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: ModelType + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) deserializer.key_extractors = ( # type: ignore @@ -500,7 +412,7 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + result |= objects[valuetype]._flatten_subtype(key, objects) # pylint: disable=protected-access return result @classmethod @@ -614,7 +526,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -626,7 +538,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) @@ -665,7 +577,7 @@ def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, to if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) + serialized |= target_obj.additional_properties continue try: @@ -736,8 +648,8 @@ def body(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized request body """ @@ -781,8 +693,8 @@ def url(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :rtype: str :returns: The serialized URL path - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -805,8 +717,8 @@ def query(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, list - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized query parameter """ try: @@ -835,8 +747,8 @@ def header(self, name, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None :returns: The serialized header """ try: @@ -855,9 +767,9 @@ def serialize_data(self, data, data_type, **kwargs): :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. :returns: The serialized data. :rtype: str, int, float, bool, dict, list """ @@ -875,7 +787,7 @@ def serialize_data(self, data, data_type, **kwargs): # If dependencies is empty, try with current data class # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) + enum_type = self.dependencies.get(data_type, cast(type, data.__class__)) if issubclass(enum_type, Enum): return Serializer.serialize_enum(data, enum_obj=enum_type) @@ -909,13 +821,20 @@ def serialize_basic(cls, data, data_type, **kwargs): :param str data_type: Type of object in the iterable. :rtype: str, int, float, bool :return: serialized object + :raises TypeError: raise if data_type is not one of str, int, float, bool. """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(data) + if data_type == "float": + return float(data) + if data_type == "bool": + return bool(data) + raise TypeError("Unknown basic data type: {}".format(data_type)) @classmethod def serialize_unicode(cls, data): @@ -1192,7 +1111,7 @@ def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. :return: serialized rfc """ try: @@ -1218,7 +1137,7 @@ def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. :return: serialized iso """ if isinstance(attr, str): @@ -1251,7 +1170,7 @@ def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid :return: serialied unix """ if isinstance(attr, int): @@ -1270,7 +1189,7 @@ def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argumen while "." in key: # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) + dict_keys = cast(list[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1429,7 +1348,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) @@ -1472,7 +1391,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.dependencies: dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1488,7 +1407,7 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1502,7 +1421,7 @@ def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1717,7 +1636,7 @@ def deserialize_data(self, data, data_type): # pylint: disable=too-many-return- :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. :rtype: object """ @@ -1799,7 +1718,7 @@ def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return :param dict attr: Dictionary to be deserialized. :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None @@ -1845,7 +1764,7 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return :param str data_type: deserialization data type. :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid or data_type is not one of str, int, float, bool. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1871,7 +1790,11 @@ def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used + if data_type == "int": + return int(attr) + if data_type == "float": + return float(attr) + raise TypeError("Unknown basic data type: {}".format(data_type)) @staticmethod def deserialize_unicode(data): @@ -1936,7 +1859,7 @@ def deserialize_bytearray(attr): :param str attr: response string to be deserialized. :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1949,7 +1872,7 @@ def deserialize_base64(attr): :param str attr: response string to be deserialized. :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1964,7 +1887,7 @@ def deserialize_decimal(attr): :param str attr: response string to be deserialized. :return: Deserialized decimal - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. :rtype: decimal """ if isinstance(attr, ET.Element): @@ -1982,7 +1905,7 @@ def deserialize_long(attr): :param str attr: response string to be deserialized. :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1995,7 +1918,7 @@ def deserialize_duration(attr): :param str attr: response string to be deserialized. :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2013,7 +1936,7 @@ def deserialize_date(attr): :param str attr: response string to be deserialized. :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2029,7 +1952,7 @@ def deserialize_time(attr): :param str attr: response string to be deserialized. :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2044,14 +1967,14 @@ def deserialize_rfc(attr): :param str attr: response string to be deserialized. :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -2067,7 +1990,7 @@ def deserialize_iso(attr): :param str attr: response string to be deserialized. :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -2105,7 +2028,7 @@ def deserialize_unix(attr): :param int attr: Object to be serialized. :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/utils.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/utils.py new file mode 100644 index 000000000000..927adb7c8ae2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_utils/utils.py @@ -0,0 +1,57 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import Generic, Optional, TYPE_CHECKING, TypeVar + +from azure.core import MatchConditions + +if TYPE_CHECKING: + from .serialization import Deserializer, Serializer + + +TClient = TypeVar("TClient") +TConfig = TypeVar("TConfig") + + +class ClientMixinABC(ABC, Generic[TClient, TConfig]): + """DO NOT use this class. It is for internal typing use only.""" + + _client: TClient + _config: TConfig + _serialize: "Serializer" + _deserialize: "Deserializer" + + +def quote_etag(etag: Optional[str]) -> Optional[str]: + if not etag or etag == "*": + return etag + if etag.startswith("W/"): + return etag + if etag.startswith('"') and etag.endswith('"'): + return etag + if etag.startswith("'") and etag.endswith("'"): + return etag + return '"' + etag + '"' + + +def prep_if_match(etag: Optional[str], match_condition: Optional[MatchConditions]) -> Optional[str]: + if match_condition == MatchConditions.IfNotModified: + if_match = quote_etag(etag) if etag else None + return if_match + if match_condition == MatchConditions.IfPresent: + return "*" + return None + + +def prep_if_none_match(etag: Optional[str], match_condition: Optional[MatchConditions]) -> Optional[str]: + if match_condition == MatchConditions.IfModified: + if_none_match = quote_etag(etag) if etag else None + return if_none_match + if match_condition == MatchConditions.IfMissing: + return "*" + return None diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py deleted file mode 100644 index f2113d194e26..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import ApiManagementClientConfiguration - -if TYPE_CHECKING: - from azure.core import PipelineClient - - from ._serialization import Deserializer, Serializer - - -class ApiManagementClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "PipelineClient" - _config: ApiManagementClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" 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 34ea7990c4b4..858d8cac6565 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py @@ -2,8 +2,8 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.0" +VERSION = "6.0.0b1" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py index 919785baa0ce..5dd77e4afbab 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._api_management_client import ApiManagementClient # type: ignore +from ._client import ApiManagementClient # type: ignore try: from ._patch import __all__ as _patch_all 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/_client.py similarity index 93% rename from sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py rename to sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_client.py index 9909f2d36dce..97d657be1ca9 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/_client.py @@ -2,32 +2,33 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints -from .. import models as _models -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import ApiManagementClientConfiguration from .operations import ( AllPoliciesOperations, ApiDiagnosticOperations, ApiExportOperations, ApiGatewayConfigConnectionOperations, + ApiGatewayHostnameBindingOperations, ApiGatewayOperations, ApiIssueAttachmentOperations, ApiIssueCommentOperations, ApiIssueOperations, - ApiManagementClientOperationsMixin, ApiManagementGatewaySkusOperations, ApiManagementOperationsOperations, ApiManagementServiceOperations, @@ -44,6 +45,7 @@ ApiRevisionOperations, ApiSchemaOperations, ApiTagDescriptionOperations, + ApiToolOperations, ApiVersionSetOperations, ApiWikiOperations, ApiWikisOperations, @@ -55,6 +57,8 @@ BackendOperations, CacheOperations, CertificateOperations, + ClientApplicationOperations, + ClientApplicationProductLinkOperations, ContentItemOperations, ContentTypeOperations, DelegationSettingsOperations, @@ -156,26 +160,172 @@ WorkspaceTagOperationLinkOperations, WorkspaceTagOperations, WorkspaceTagProductLinkOperations, + _ApiManagementClientOperationsMixin, ) if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential -class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes - """ApiManagement Client. +class ApiManagementClient(_ApiManagementClientOperationsMixin): # pylint: disable=too-many-instance-attributes + """Resource provider operation status. + :ivar workspace_api: WorkspaceApiOperations operations + :vartype workspace_api: azure.mgmt.apimanagement.aio.operations.WorkspaceApiOperations + :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 graph_ql_api_resolver_policy: GraphQLApiResolverPolicyOperations operations + :vartype graph_ql_api_resolver_policy: + azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverPolicyOperations + :ivar api_policy: ApiPolicyOperations operations + :vartype api_policy: azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations + :ivar policy: PolicyOperations operations + :vartype policy: azure.mgmt.apimanagement.aio.operations.PolicyOperations + :ivar product_policy: ProductPolicyOperations operations + :vartype product_policy: azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations + :ivar workspace_policy: WorkspacePolicyOperations operations + :vartype workspace_policy: azure.mgmt.apimanagement.aio.operations.WorkspacePolicyOperations + :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_product_policy: WorkspaceProductPolicyOperations operations + :vartype workspace_product_policy: + azure.mgmt.apimanagement.aio.operations.WorkspaceProductPolicyOperations + :ivar tag: TagOperations operations + :vartype tag: azure.mgmt.apimanagement.aio.operations.TagOperations + :ivar workspace_tag: WorkspaceTagOperations operations + :vartype workspace_tag: azure.mgmt.apimanagement.aio.operations.WorkspaceTagOperations + :ivar workspace_api_schema: WorkspaceApiSchemaOperations operations + :vartype workspace_api_schema: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiSchemaOperations + :ivar diagnostic: DiagnosticOperations operations + :vartype diagnostic: azure.mgmt.apimanagement.aio.operations.DiagnosticOperations + :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 issue: IssueOperations operations + :vartype issue: azure.mgmt.apimanagement.aio.operations.IssueOperations + :ivar product_wiki: ProductWikiOperations operations + :vartype product_wiki: azure.mgmt.apimanagement.aio.operations.ProductWikiOperations + :ivar workspace_api_version_set: WorkspaceApiVersionSetOperations operations + :vartype workspace_api_version_set: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiVersionSetOperations + :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_group: WorkspaceGroupOperations operations + :vartype workspace_group: azure.mgmt.apimanagement.aio.operations.WorkspaceGroupOperations + :ivar workspace_logger: WorkspaceLoggerOperations operations + :vartype workspace_logger: azure.mgmt.apimanagement.aio.operations.WorkspaceLoggerOperations + :ivar workspace_named_value: WorkspaceNamedValueOperations operations + :vartype workspace_named_value: + azure.mgmt.apimanagement.aio.operations.WorkspaceNamedValueOperations + :ivar workspace_notification: WorkspaceNotificationOperations operations + :vartype workspace_notification: + azure.mgmt.apimanagement.aio.operations.WorkspaceNotificationOperations + :ivar workspace_policy_fragment: WorkspacePolicyFragmentOperations operations + :vartype workspace_policy_fragment: + azure.mgmt.apimanagement.aio.operations.WorkspacePolicyFragmentOperations + :ivar sign_in_settings: SignInSettingsOperations operations + :vartype sign_in_settings: azure.mgmt.apimanagement.aio.operations.SignInSettingsOperations + :ivar sign_up_settings: SignUpSettingsOperations operations + :vartype sign_up_settings: azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations + :ivar delegation_settings: DelegationSettingsOperations operations + :vartype delegation_settings: + azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations + :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_global_schema: WorkspaceGlobalSchemaOperations operations + :vartype workspace_global_schema: + azure.mgmt.apimanagement.aio.operations.WorkspaceGlobalSchemaOperations + :ivar user_subscription: UserSubscriptionOperations operations + :vartype user_subscription: azure.mgmt.apimanagement.aio.operations.UserSubscriptionOperations + :ivar workspace_subscription: WorkspaceSubscriptionOperations operations + :vartype workspace_subscription: + azure.mgmt.apimanagement.aio.operations.WorkspaceSubscriptionOperations + :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 api_management_operations: ApiManagementOperationsOperations operations + :vartype api_management_operations: + azure.mgmt.apimanagement.aio.operations.ApiManagementOperationsOperations :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 all_policies: AllPoliciesOperations operations - :vartype all_policies: azure.mgmt.apimanagement.aio.operations.AllPoliciesOperations :ivar api: ApiOperations operations :vartype api: azure.mgmt.apimanagement.aio.operations.ApiOperations :ivar api_revision: ApiRevisionOperations operations :vartype api_revision: azure.mgmt.apimanagement.aio.operations.ApiRevisionOperations + :ivar api_product: ApiProductOperations operations + :vartype api_product: azure.mgmt.apimanagement.aio.operations.ApiProductOperations + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.apimanagement.aio.operations.OperationOperations + :ivar workspace_api_revision: WorkspaceApiRevisionOperations operations + :vartype workspace_api_revision: + azure.mgmt.apimanagement.aio.operations.WorkspaceApiRevisionOperations + :ivar api_management_service: ApiManagementServiceOperations operations + :vartype api_management_service: + azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations + :ivar all_policies: AllPoliciesOperations operations + :vartype all_policies: azure.mgmt.apimanagement.aio.operations.AllPoliciesOperations + :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations + :vartype api_management_service_skus: + azure.mgmt.apimanagement.aio.operations.ApiManagementServiceSkusOperations + :ivar network_status: NetworkStatusOperations operations + :vartype network_status: azure.mgmt.apimanagement.aio.operations.NetworkStatusOperations + :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations + operations + :vartype outbound_network_dependencies_endpoints: + azure.mgmt.apimanagement.aio.operations.OutboundNetworkDependenciesEndpointsOperations + :ivar policy_description: PolicyDescriptionOperations operations + :vartype policy_description: + azure.mgmt.apimanagement.aio.operations.PolicyDescriptionOperations + :ivar policy_restriction_validations: PolicyRestrictionValidationsOperations operations + :vartype policy_restriction_validations: + azure.mgmt.apimanagement.aio.operations.PolicyRestrictionValidationsOperations + :ivar portal_settings: PortalSettingsOperations operations + :vartype portal_settings: azure.mgmt.apimanagement.aio.operations.PortalSettingsOperations + :ivar product: ProductOperations operations + :vartype product: azure.mgmt.apimanagement.aio.operations.ProductOperations + :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations + :vartype quota_by_counter_keys: + azure.mgmt.apimanagement.aio.operations.QuotaByCounterKeysOperations + :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations + :vartype quota_by_period_keys: + azure.mgmt.apimanagement.aio.operations.QuotaByPeriodKeysOperations + :ivar region: RegionOperations operations + :vartype region: azure.mgmt.apimanagement.aio.operations.RegionOperations + :ivar reports: ReportsOperations operations + :vartype reports: azure.mgmt.apimanagement.aio.operations.ReportsOperations + :ivar tag_resource: TagResourceOperations operations + :vartype tag_resource: azure.mgmt.apimanagement.aio.operations.TagResourceOperations :ivar api_release: ApiReleaseOperations operations :vartype api_release: azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations :ivar api_operation: ApiOperationOperations operations @@ -183,18 +333,9 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :ivar api_operation_policy: ApiOperationPolicyOperations operations :vartype api_operation_policy: azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations - :ivar tag: TagOperations operations - :vartype tag: azure.mgmt.apimanagement.aio.operations.TagOperations :ivar graph_ql_api_resolver: GraphQLApiResolverOperations operations :vartype graph_ql_api_resolver: azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverOperations - :ivar graph_ql_api_resolver_policy: GraphQLApiResolverPolicyOperations operations - :vartype graph_ql_api_resolver_policy: - azure.mgmt.apimanagement.aio.operations.GraphQLApiResolverPolicyOperations - :ivar api_product: ApiProductOperations operations - :vartype api_product: azure.mgmt.apimanagement.aio.operations.ApiProductOperations - :ivar api_policy: ApiPolicyOperations operations - :vartype api_policy: azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations :ivar api_schema: ApiSchemaOperations operations :vartype api_schema: azure.mgmt.apimanagement.aio.operations.ApiSchemaOperations :ivar api_diagnostic: ApiDiagnosticOperations operations @@ -209,14 +350,14 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :ivar api_tag_description: ApiTagDescriptionOperations operations :vartype api_tag_description: azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations - :ivar operation: OperationOperations operations - :vartype operation: azure.mgmt.apimanagement.aio.operations.OperationOperations :ivar api_wiki: ApiWikiOperations operations :vartype api_wiki: azure.mgmt.apimanagement.aio.operations.ApiWikiOperations :ivar api_wikis: ApiWikisOperations operations :vartype api_wikis: azure.mgmt.apimanagement.aio.operations.ApiWikisOperations - :ivar api_export: ApiExportOperations operations - :vartype api_export: azure.mgmt.apimanagement.aio.operations.ApiExportOperations + :ivar product_wikis: ProductWikisOperations operations + :vartype product_wikis: azure.mgmt.apimanagement.aio.operations.ProductWikisOperations + :ivar api_tool: ApiToolOperations operations + :vartype api_tool: azure.mgmt.apimanagement.aio.operations.ApiToolOperations :ivar api_version_set: ApiVersionSetOperations operations :vartype api_version_set: azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations :ivar authorization_provider: AuthorizationProviderOperations operations @@ -245,17 +386,6 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :vartype content_item: azure.mgmt.apimanagement.aio.operations.ContentItemOperations :ivar deleted_services: DeletedServicesOperations operations :vartype deleted_services: azure.mgmt.apimanagement.aio.operations.DeletedServicesOperations - :ivar api_management_operations: ApiManagementOperationsOperations operations - :vartype api_management_operations: - azure.mgmt.apimanagement.aio.operations.ApiManagementOperationsOperations - :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations - :vartype api_management_service_skus: - azure.mgmt.apimanagement.aio.operations.ApiManagementServiceSkusOperations - :ivar api_management_service: ApiManagementServiceOperations operations - :vartype api_management_service: - 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 @@ -263,13 +393,16 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :ivar api_gateway_config_connection: ApiGatewayConfigConnectionOperations operations :vartype api_gateway_config_connection: azure.mgmt.apimanagement.aio.operations.ApiGatewayConfigConnectionOperations + :ivar api_gateway_hostname_binding: ApiGatewayHostnameBindingOperations operations + :vartype api_gateway_hostname_binding: + azure.mgmt.apimanagement.aio.operations.ApiGatewayHostnameBindingOperations :ivar gateway: GatewayOperations operations :vartype gateway: azure.mgmt.apimanagement.aio.operations.GatewayOperations + :ivar gateway_api: GatewayApiOperations operations + :vartype gateway_api: azure.mgmt.apimanagement.aio.operations.GatewayApiOperations :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations :vartype gateway_hostname_configuration: azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations - :ivar gateway_api: GatewayApiOperations operations - :vartype gateway_api: azure.mgmt.apimanagement.aio.operations.GatewayApiOperations :ivar gateway_certificate_authority: GatewayCertificateAuthorityOperations operations :vartype gateway_certificate_authority: azure.mgmt.apimanagement.aio.operations.GatewayCertificateAuthorityOperations @@ -277,16 +410,15 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :vartype group: azure.mgmt.apimanagement.aio.operations.GroupOperations :ivar group_user: GroupUserOperations operations :vartype group_user: azure.mgmt.apimanagement.aio.operations.GroupUserOperations + :ivar workspace_group_user: WorkspaceGroupUserOperations operations + :vartype workspace_group_user: + azure.mgmt.apimanagement.aio.operations.WorkspaceGroupUserOperations :ivar identity_provider: IdentityProviderOperations operations :vartype identity_provider: azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations - :ivar issue: IssueOperations operations - :vartype issue: azure.mgmt.apimanagement.aio.operations.IssueOperations :ivar logger: LoggerOperations operations :vartype logger: azure.mgmt.apimanagement.aio.operations.LoggerOperations :ivar named_value: NamedValueOperations operations :vartype named_value: azure.mgmt.apimanagement.aio.operations.NamedValueOperations - :ivar network_status: NetworkStatusOperations operations - :vartype network_status: azure.mgmt.apimanagement.aio.operations.NetworkStatusOperations :ivar notification: NotificationOperations operations :vartype notification: azure.mgmt.apimanagement.aio.operations.NotificationOperations :ivar notification_recipient_user: NotificationRecipientUserOperations operations @@ -295,44 +427,35 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :ivar notification_recipient_email: NotificationRecipientEmailOperations operations :vartype notification_recipient_email: azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations + :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 open_id_connect_provider: OpenIdConnectProviderOperations operations :vartype open_id_connect_provider: azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations - :ivar outbound_network_dependencies_endpoints: OutboundNetworkDependenciesEndpointsOperations - operations - :vartype outbound_network_dependencies_endpoints: - azure.mgmt.apimanagement.aio.operations.OutboundNetworkDependenciesEndpointsOperations - :ivar policy: PolicyOperations operations - :vartype policy: azure.mgmt.apimanagement.aio.operations.PolicyOperations - :ivar policy_description: PolicyDescriptionOperations operations - :vartype policy_description: - 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 client_application: ClientApplicationOperations operations + :vartype client_application: + azure.mgmt.apimanagement.aio.operations.ClientApplicationOperations + :ivar client_application_product_link: ClientApplicationProductLinkOperations operations + :vartype client_application_product_link: + azure.mgmt.apimanagement.aio.operations.ClientApplicationProductLinkOperations :ivar portal_revision: PortalRevisionOperations operations :vartype portal_revision: azure.mgmt.apimanagement.aio.operations.PortalRevisionOperations - :ivar portal_settings: PortalSettingsOperations operations - :vartype portal_settings: azure.mgmt.apimanagement.aio.operations.PortalSettingsOperations - :ivar sign_in_settings: SignInSettingsOperations operations - :vartype sign_in_settings: azure.mgmt.apimanagement.aio.operations.SignInSettingsOperations - :ivar sign_up_settings: SignUpSettingsOperations operations - :vartype sign_up_settings: azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations - :ivar delegation_settings: DelegationSettingsOperations operations - :vartype delegation_settings: - azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations :ivar private_endpoint_connection: PrivateEndpointConnectionOperations operations :vartype private_endpoint_connection: azure.mgmt.apimanagement.aio.operations.PrivateEndpointConnectionOperations - :ivar product: ProductOperations operations - :vartype product: azure.mgmt.apimanagement.aio.operations.ProductOperations :ivar product_api: ProductApiOperations operations :vartype product_api: azure.mgmt.apimanagement.aio.operations.ProductApiOperations :ivar product_group: ProductGroupOperations operations @@ -340,37 +463,16 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :ivar product_subscriptions: ProductSubscriptionsOperations operations :vartype product_subscriptions: azure.mgmt.apimanagement.aio.operations.ProductSubscriptionsOperations - :ivar product_policy: ProductPolicyOperations operations - :vartype product_policy: azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations - :ivar product_wiki: ProductWikiOperations operations - :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 - :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations - :vartype quota_by_period_keys: - azure.mgmt.apimanagement.aio.operations.QuotaByPeriodKeysOperations - :ivar region: RegionOperations operations - :vartype region: azure.mgmt.apimanagement.aio.operations.RegionOperations - :ivar reports: ReportsOperations operations - :vartype reports: azure.mgmt.apimanagement.aio.operations.ReportsOperations :ivar global_schema: GlobalSchemaOperations operations :vartype global_schema: azure.mgmt.apimanagement.aio.operations.GlobalSchemaOperations :ivar tenant_settings: TenantSettingsOperations operations :vartype tenant_settings: azure.mgmt.apimanagement.aio.operations.TenantSettingsOperations - :ivar api_management_skus: ApiManagementSkusOperations operations - :vartype api_management_skus: - azure.mgmt.apimanagement.aio.operations.ApiManagementSkusOperations :ivar subscription: SubscriptionOperations operations :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 @@ -388,109 +490,24 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :vartype user: azure.mgmt.apimanagement.aio.operations.UserOperations :ivar user_group: UserGroupOperations operations :vartype user_group: azure.mgmt.apimanagement.aio.operations.UserGroupOperations - :ivar user_subscription: UserSubscriptionOperations operations - :vartype user_subscription: azure.mgmt.apimanagement.aio.operations.UserSubscriptionOperations :ivar user_identities: UserIdentitiesOperations operations :vartype user_identities: azure.mgmt.apimanagement.aio.operations.UserIdentitiesOperations :ivar user_confirmation_password: UserConfirmationPasswordOperations operations :vartype user_confirmation_password: azure.mgmt.apimanagement.aio.operations.UserConfirmationPasswordOperations - :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 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_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 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 api_export: ApiExportOperations operations + :vartype api_export: azure.mgmt.apimanagement.aio.operations.ApiExportOperations + :ivar api_management_skus: ApiManagementSkusOperations operations + :vartype api_management_skus: + azure.mgmt.apimanagement.aio.operations.ApiManagementSkusOperations :ivar workspace_api_export: WorkspaceApiExportOperations operations :vartype workspace_api_export: azure.mgmt.apimanagement.aio.operations.WorkspaceApiExportOperations @@ -499,14 +516,18 @@ class ApiManagementClient(ApiManagementClientOperationsMixin): # pylint: disabl :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. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :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". + :param base_url: Service host. Default value is None. :type base_url: str - :keyword api_version: Api Version. Default value is "2024-05-01". Note that overriding this - default value may result in unsupported behavior. + :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :paramtype cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-03-01-preview". Default value is "2025-03-01-preview". 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 Retry-After header is present. @@ -516,12 +537,26 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: str = "https://management.azure.com", + base_url: Optional[str] = None, + *, + cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" + _cloud = cloud_setting or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = ApiManagementClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, + subscription_id=subscription_id, + base_url=cast(str, base_url), + cloud_setting=cloud_setting, + credential_scopes=credential_scopes, + **kwargs ) + _policies = kwargs.pop("policies", None) if _policies is None: _policies = [ @@ -540,151 +575,139 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, _endpoint), policies=_policies, **kwargs + ) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.api_gateway = ApiGatewayOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_management_gateway_skus = ApiManagementGatewaySkusOperations( + self.workspace_api = WorkspaceApiOperations(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.graph_ql_api_resolver_policy = GraphQLApiResolverPolicyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.api_policy = ApiPolicyOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_policy = ProductPolicyOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_policy = WorkspacePolicyOperations( self._client, self._config, self._serialize, self._deserialize ) - self.all_policies = AllPoliciesOperations(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) - self.api_operation = ApiOperationOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_operation_policy = ApiOperationPolicyOperations( + 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_product_policy = WorkspaceProductPolicyOperations( self._client, self._config, self._serialize, self._deserialize ) self.tag = TagOperations(self._client, self._config, self._serialize, self._deserialize) - self.graph_ql_api_resolver = GraphQLApiResolverOperations( + self.workspace_tag = WorkspaceTagOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_api_schema = WorkspaceApiSchemaOperations( self._client, self._config, self._serialize, self._deserialize ) - self.graph_ql_api_resolver_policy = GraphQLApiResolverPolicyOperations( + self.diagnostic = DiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_diagnostic = WorkspaceDiagnosticOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_product = ApiProductOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_policy = ApiPolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_schema = ApiSchemaOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_diagnostic = ApiDiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_issue = ApiIssueOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_issue_comment = ApiIssueCommentOperations( + self.workspace_api_diagnostic = WorkspaceApiDiagnosticOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_issue_attachment = ApiIssueAttachmentOperations( + self.issue = IssueOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_wiki = ProductWikiOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_api_version_set = WorkspaceApiVersionSetOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_tag_description = ApiTagDescriptionOperations( + self.workspace_backend = WorkspaceBackendOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_wiki = ApiWikiOperations(self._client, self._config, self._serialize, self._deserialize) - 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_provider = AuthorizationProviderOperations( + self.workspace_certificate = WorkspaceCertificateOperations( self._client, self._config, self._serialize, self._deserialize ) - self.authorization = AuthorizationOperations(self._client, self._config, self._serialize, self._deserialize) - self.authorization_login_links = AuthorizationLoginLinksOperations( + self.workspace_group = WorkspaceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_logger = WorkspaceLoggerOperations( self._client, self._config, self._serialize, self._deserialize ) - self.authorization_access_policy = AuthorizationAccessPolicyOperations( + self.workspace_named_value = WorkspaceNamedValueOperations( self._client, self._config, self._serialize, self._deserialize ) - self.authorization_server = AuthorizationServerOperations( + self.workspace_notification = WorkspaceNotificationOperations( 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) - self.content_type = ContentTypeOperations(self._client, self._config, self._serialize, self._deserialize) - self.content_item = ContentItemOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_services = DeletedServicesOperations( + self.workspace_policy_fragment = WorkspacePolicyFragmentOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_operations = ApiManagementOperationsOperations( + self.sign_in_settings = SignInSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.sign_up_settings = SignUpSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.delegation_settings = DelegationSettingsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_service_skus = ApiManagementServiceSkusOperations( + self.workspace_product = WorkspaceProductOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_service = ApiManagementServiceOperations( + self.workspace_product_api_link = WorkspaceProductApiLinkOperations( 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.api_gateway_config_connection = ApiGatewayConfigConnectionOperations( + self.workspace_product_group_link = WorkspaceProductGroupLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.gateway = GatewayOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations( + self.workspace_global_schema = WorkspaceGlobalSchemaOperations( self._client, self._config, self._serialize, self._deserialize ) - self.gateway_api = GatewayApiOperations(self._client, self._config, self._serialize, self._deserialize) - self.gateway_certificate_authority = GatewayCertificateAuthorityOperations( + self.user_subscription = UserSubscriptionOperations( 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( + self.workspace_subscription = WorkspaceSubscriptionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.issue = IssueOperations(self._client, self._config, self._serialize, self._deserialize) - self.logger = LoggerOperations(self._client, self._config, self._serialize, self._deserialize) - self.named_value = NamedValueOperations(self._client, self._config, self._serialize, self._deserialize) - self.network_status = NetworkStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.notification = NotificationOperations(self._client, self._config, self._serialize, self._deserialize) - self.notification_recipient_user = NotificationRecipientUserOperations( + self.workspace_tag_api_link = WorkspaceTagApiLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.notification_recipient_email = NotificationRecipientEmailOperations( + self.workspace_tag_operation_link = WorkspaceTagOperationLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.open_id_connect_provider = OpenIdConnectProviderOperations( + self.workspace_tag_product_link = WorkspaceTagProductLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.outbound_network_dependencies_endpoints = OutboundNetworkDependenciesEndpointsOperations( + self.api_management_operations = ApiManagementOperationsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy = PolicyOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_description = PolicyDescriptionOperations( + 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.policy_fragment = PolicyFragmentOperations(self._client, self._config, self._serialize, self._deserialize) - self.policy_restriction = PolicyRestrictionOperations( + 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_product = ApiProductOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_api_revision = WorkspaceApiRevisionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.policy_restriction_validations = PolicyRestrictionValidationsOperations( + self.api_management_service = ApiManagementServiceOperations( 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) - self.sign_in_settings = SignInSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.sign_up_settings = SignUpSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.delegation_settings = DelegationSettingsOperations( + self.all_policies = AllPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_management_service_skus = ApiManagementServiceSkusOperations( self._client, self._config, self._serialize, self._deserialize ) - self.private_endpoint_connection = PrivateEndpointConnectionOperations( + self.network_status = NetworkStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.outbound_network_dependencies_endpoints = OutboundNetworkDependenciesEndpointsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.product = ProductOperations(self._client, self._config, self._serialize, self._deserialize) - self.product_api = ProductApiOperations(self._client, self._config, self._serialize, self._deserialize) - self.product_group = ProductGroupOperations(self._client, self._config, self._serialize, self._deserialize) - self.product_subscriptions = ProductSubscriptionsOperations( + self.policy_description = PolicyDescriptionOperations( self._client, self._config, self._serialize, self._deserialize ) - 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.policy_restriction_validations = PolicyRestrictionValidationsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.portal_settings = PortalSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.product = ProductOperations(self._client, self._config, self._serialize, self._deserialize) self.quota_by_counter_keys = QuotaByCounterKeysOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -693,126 +716,149 @@ def __init__( ) self.region = RegionOperations(self._client, self._config, self._serialize, self._deserialize) self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) - self.global_schema = GlobalSchemaOperations(self._client, self._config, self._serialize, self._deserialize) - self.tenant_settings = TenantSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.api_management_skus = ApiManagementSkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) - 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.api_release = ApiReleaseOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_operation = ApiOperationOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_operation_policy = ApiOperationPolicyOperations( self._client, self._config, self._serialize, self._deserialize ) - self.tenant_configuration = TenantConfigurationOperations( + self.graph_ql_api_resolver = GraphQLApiResolverOperations( self._client, self._config, self._serialize, self._deserialize ) - self.user = UserOperations(self._client, self._config, self._serialize, self._deserialize) - self.user_group = UserGroupOperations(self._client, self._config, self._serialize, self._deserialize) - self.user_subscription = UserSubscriptionOperations( + self.api_schema = ApiSchemaOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_diagnostic = ApiDiagnosticOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_issue = ApiIssueOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_issue_comment = ApiIssueCommentOperations( self._client, self._config, self._serialize, self._deserialize ) - self.user_identities = UserIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) - self.user_confirmation_password = UserConfirmationPasswordOperations( + self.api_issue_attachment = ApiIssueAttachmentOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_backend = WorkspaceBackendOperations( + self.api_tag_description = ApiTagDescriptionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_certificate = WorkspaceCertificateOperations( + self.api_wiki = ApiWikiOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_wikis = ApiWikisOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_wikis = ProductWikisOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_tool = ApiToolOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_version_set = ApiVersionSetOperations(self._client, self._config, self._serialize, self._deserialize) + self.authorization_provider = AuthorizationProviderOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_diagnostic = WorkspaceDiagnosticOperations( + self.authorization = AuthorizationOperations(self._client, self._config, self._serialize, self._deserialize) + self.authorization_login_links = AuthorizationLoginLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_diagnostic = WorkspaceApiDiagnosticOperations( + self.authorization_access_policy = AuthorizationAccessPolicyOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_workspace_links = ApiManagementWorkspaceLinksOperations( + self.authorization_server = AuthorizationServerOperations( self._client, self._config, self._serialize, self._deserialize ) - self.api_management_workspace_link = ApiManagementWorkspaceLinkOperations( + 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) + self.content_type = ContentTypeOperations(self._client, self._config, self._serialize, self._deserialize) + self.content_item = ContentItemOperations(self._client, self._config, self._serialize, self._deserialize) + self.deleted_services = DeletedServicesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_logger = WorkspaceLoggerOperations( + self.documentation = DocumentationOperations(self._client, self._config, self._serialize, self._deserialize) + self.email_template = EmailTemplateOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_gateway_config_connection = ApiGatewayConfigConnectionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace = WorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspace_policy = WorkspacePolicyOperations( + self.api_gateway_hostname_binding = ApiGatewayHostnameBindingOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_named_value = WorkspaceNamedValueOperations( + self.gateway = GatewayOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_api = GatewayApiOperations(self._client, self._config, self._serialize, self._deserialize) + self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_global_schema = WorkspaceGlobalSchemaOperations( + self.gateway_certificate_authority = GatewayCertificateAuthorityOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_notification = WorkspaceNotificationOperations( + self.group = GroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.group_user = GroupUserOperations(self._client, self._config, self._serialize, self._deserialize) + self.workspace_group_user = WorkspaceGroupUserOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_notification_recipient_user = WorkspaceNotificationRecipientUserOperations( + self.identity_provider = IdentityProviderOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_notification_recipient_email = WorkspaceNotificationRecipientEmailOperations( + self.logger = LoggerOperations(self._client, self._config, self._serialize, self._deserialize) + self.named_value = NamedValueOperations(self._client, self._config, self._serialize, self._deserialize) + self.notification = NotificationOperations(self._client, self._config, self._serialize, self._deserialize) + self.notification_recipient_user = NotificationRecipientUserOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_policy_fragment = WorkspacePolicyFragmentOperations( + self.notification_recipient_email = NotificationRecipientEmailOperations( 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.workspace_notification_recipient_user = WorkspaceNotificationRecipientUserOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_subscription = WorkspaceSubscriptionOperations( + self.workspace_notification_recipient_email = WorkspaceNotificationRecipientEmailOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_version_set = WorkspaceApiVersionSetOperations( + self.open_id_connect_provider = OpenIdConnectProviderOperations( 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.policy_fragment = PolicyFragmentOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_restriction = PolicyRestrictionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_release = WorkspaceApiReleaseOperations( + self.portal_config = PortalConfigOperations(self._client, self._config, self._serialize, self._deserialize) + self.client_application = ClientApplicationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_operation = WorkspaceApiOperationOperations( + self.client_application_product_link = ClientApplicationProductLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_operation_policy = WorkspaceApiOperationPolicyOperations( + self.portal_revision = PortalRevisionOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connection = PrivateEndpointConnectionOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_policy = WorkspaceApiPolicyOperations( + self.product_api = ProductApiOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_group = ProductGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.product_subscriptions = ProductSubscriptionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_api_schema = WorkspaceApiSchemaOperations( + 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.workspace_product = WorkspaceProductOperations( + self.global_schema = GlobalSchemaOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_settings = TenantSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations(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.workspace_product_api_link = WorkspaceProductApiLinkOperations( + 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 ) - self.workspace_product_group_link = WorkspaceProductGroupLinkOperations( + self.tenant_configuration = TenantConfigurationOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_product_policy = WorkspaceProductPolicyOperations( + self.user = UserOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_group = UserGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_identities = UserIdentitiesOperations(self._client, self._config, self._serialize, self._deserialize) + self.user_confirmation_password = UserConfirmationPasswordOperations( 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.api_management_workspace_link = ApiManagementWorkspaceLinkOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_tag_operation_link = WorkspaceTagOperationLinkOperations( + self.api_management_workspace_links = ApiManagementWorkspaceLinksOperations( self._client, self._config, self._serialize, self._deserialize ) - self.workspace_tag_product_link = WorkspaceTagProductLinkOperations( + self.workspace = WorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_export = ApiExportOperations(self._client, self._config, self._serialize, self._deserialize) + self.api_management_skus = ApiManagementSkusOperations( self._client, self._config, self._serialize, self._deserialize ) self.workspace_api_export = WorkspaceApiExportOperations( @@ -825,7 +871,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -833,7 +879,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -846,7 +892,11 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: 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 e98cd26fa776..84e7b6bf4c8a 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 @@ -2,11 +2,11 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -14,6 +14,7 @@ from .._version import VERSION if TYPE_CHECKING: + from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential @@ -23,17 +24,30 @@ class ApiManagementClientConfiguration: # pylint: disable=too-many-instance-att Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :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 "2024-05-01". Note that overriding this - default value may result in unsupported behavior. + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str + :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is + None. + :type cloud_setting: ~azure.core.AzureClouds + :keyword api_version: The API version to use for this operation. Known values are + "2025-03-01-preview". Default value is "2025-03-01-preview". 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", "2024-05-01") + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + cloud_setting: Optional["AzureClouds"] = None, + **kwargs: Any + ) -> None: + api_version: str = kwargs.pop("api_version", "2025-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -42,6 +56,8 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url + self.cloud_setting = cloud_setting self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-apimanagement/{}".format(VERSION)) 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 17dbc073e01b..87676c65a8f0 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 @@ -1,32 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level -# 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(): - pass + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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 deleted file mode 100644 index 2e1a55b2278d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import ApiManagementClientConfiguration - -if TYPE_CHECKING: - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class ApiManagementClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: ApiManagementClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" 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 203221376c61..e3b8884a66e9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,172 +12,228 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._api_gateway_operations import ApiGatewayOperations # type: ignore -from ._api_management_gateway_skus_operations import ApiManagementGatewaySkusOperations # type: ignore -from ._all_policies_operations import AllPoliciesOperations # type: ignore -from ._api_operations import ApiOperations # type: ignore -from ._api_revision_operations import ApiRevisionOperations # type: ignore -from ._api_release_operations import ApiReleaseOperations # type: ignore -from ._api_operation_operations import ApiOperationOperations # type: ignore -from ._api_operation_policy_operations import ApiOperationPolicyOperations # type: ignore -from ._tag_operations import TagOperations # type: ignore -from ._graph_ql_api_resolver_operations import GraphQLApiResolverOperations # type: ignore -from ._graph_ql_api_resolver_policy_operations import GraphQLApiResolverPolicyOperations # type: ignore -from ._api_product_operations import ApiProductOperations # type: ignore -from ._api_policy_operations import ApiPolicyOperations # type: ignore -from ._api_schema_operations import ApiSchemaOperations # type: ignore -from ._api_diagnostic_operations import ApiDiagnosticOperations # type: ignore -from ._api_issue_operations import ApiIssueOperations # type: ignore -from ._api_issue_comment_operations import ApiIssueCommentOperations # type: ignore -from ._api_issue_attachment_operations import ApiIssueAttachmentOperations # type: ignore -from ._api_tag_description_operations import ApiTagDescriptionOperations # type: ignore -from ._operation_operations import OperationOperations # type: ignore -from ._api_wiki_operations import ApiWikiOperations # type: ignore -from ._api_wikis_operations import ApiWikisOperations # type: ignore -from ._api_export_operations import ApiExportOperations # type: ignore -from ._api_version_set_operations import ApiVersionSetOperations # type: ignore -from ._authorization_provider_operations import AuthorizationProviderOperations # type: ignore -from ._authorization_operations import AuthorizationOperations # type: ignore -from ._authorization_login_links_operations import AuthorizationLoginLinksOperations # type: ignore -from ._authorization_access_policy_operations import AuthorizationAccessPolicyOperations # type: ignore -from ._authorization_server_operations import AuthorizationServerOperations # type: ignore -from ._backend_operations import BackendOperations # type: ignore -from ._cache_operations import CacheOperations # type: ignore -from ._certificate_operations import CertificateOperations # type: ignore -from ._api_management_client_operations import ApiManagementClientOperationsMixin # type: ignore -from ._content_type_operations import ContentTypeOperations # type: ignore -from ._content_item_operations import ContentItemOperations # type: ignore -from ._deleted_services_operations import DeletedServicesOperations # type: ignore -from ._api_management_operations_operations import ApiManagementOperationsOperations # type: ignore -from ._api_management_service_skus_operations import ApiManagementServiceSkusOperations # type: ignore -from ._api_management_service_operations import ApiManagementServiceOperations # type: ignore -from ._diagnostic_operations import DiagnosticOperations # type: ignore -from ._documentation_operations import DocumentationOperations # type: ignore -from ._email_template_operations import EmailTemplateOperations # type: ignore -from ._api_gateway_config_connection_operations import ApiGatewayConfigConnectionOperations # type: ignore -from ._gateway_operations import GatewayOperations # type: ignore -from ._gateway_hostname_configuration_operations import GatewayHostnameConfigurationOperations # type: ignore -from ._gateway_api_operations import GatewayApiOperations # type: ignore -from ._gateway_certificate_authority_operations import GatewayCertificateAuthorityOperations # type: ignore -from ._group_operations import GroupOperations # type: ignore -from ._group_user_operations import GroupUserOperations # type: ignore -from ._identity_provider_operations import IdentityProviderOperations # type: ignore -from ._issue_operations import IssueOperations # type: ignore -from ._logger_operations import LoggerOperations # type: ignore -from ._named_value_operations import NamedValueOperations # type: ignore -from ._network_status_operations import NetworkStatusOperations # type: ignore -from ._notification_operations import NotificationOperations # type: ignore -from ._notification_recipient_user_operations import NotificationRecipientUserOperations # type: ignore -from ._notification_recipient_email_operations import NotificationRecipientEmailOperations # type: ignore -from ._open_id_connect_provider_operations import OpenIdConnectProviderOperations # type: ignore -from ._outbound_network_dependencies_endpoints_operations import OutboundNetworkDependenciesEndpointsOperations # type: ignore -from ._policy_operations import PolicyOperations # type: ignore -from ._policy_description_operations import PolicyDescriptionOperations # type: ignore -from ._policy_fragment_operations import PolicyFragmentOperations # type: ignore -from ._policy_restriction_operations import PolicyRestrictionOperations # type: ignore -from ._policy_restriction_validations_operations import PolicyRestrictionValidationsOperations # type: ignore -from ._portal_config_operations import PortalConfigOperations # type: ignore -from ._portal_revision_operations import PortalRevisionOperations # type: ignore -from ._portal_settings_operations import PortalSettingsOperations # type: ignore -from ._sign_in_settings_operations import SignInSettingsOperations # type: ignore -from ._sign_up_settings_operations import SignUpSettingsOperations # type: ignore -from ._delegation_settings_operations import DelegationSettingsOperations # type: ignore -from ._private_endpoint_connection_operations import PrivateEndpointConnectionOperations # type: ignore -from ._product_operations import ProductOperations # type: ignore -from ._product_api_operations import ProductApiOperations # type: ignore -from ._product_group_operations import ProductGroupOperations # type: ignore -from ._product_subscriptions_operations import ProductSubscriptionsOperations # type: ignore -from ._product_policy_operations import ProductPolicyOperations # type: ignore -from ._product_wiki_operations import ProductWikiOperations # type: ignore -from ._product_wikis_operations import ProductWikisOperations # type: ignore -from ._product_api_link_operations import ProductApiLinkOperations # type: ignore -from ._product_group_link_operations import ProductGroupLinkOperations # type: ignore -from ._quota_by_counter_keys_operations import QuotaByCounterKeysOperations # type: ignore -from ._quota_by_period_keys_operations import QuotaByPeriodKeysOperations # type: ignore -from ._region_operations import RegionOperations # type: ignore -from ._reports_operations import ReportsOperations # type: ignore -from ._global_schema_operations import GlobalSchemaOperations # type: ignore -from ._tenant_settings_operations import TenantSettingsOperations # type: ignore -from ._api_management_skus_operations import ApiManagementSkusOperations # type: ignore -from ._subscription_operations import SubscriptionOperations # type: ignore -from ._tag_resource_operations import TagResourceOperations # type: ignore -from ._tag_api_link_operations import TagApiLinkOperations # type: ignore -from ._tag_operation_link_operations import TagOperationLinkOperations # type: ignore -from ._tag_product_link_operations import TagProductLinkOperations # type: ignore -from ._tenant_access_operations import TenantAccessOperations # type: ignore -from ._tenant_access_git_operations import TenantAccessGitOperations # type: ignore -from ._tenant_configuration_operations import TenantConfigurationOperations # type: ignore -from ._user_operations import UserOperations # type: ignore -from ._user_group_operations import UserGroupOperations # type: ignore -from ._user_subscription_operations import UserSubscriptionOperations # type: ignore -from ._user_identities_operations import UserIdentitiesOperations # type: ignore -from ._user_confirmation_password_operations import UserConfirmationPasswordOperations # type: ignore -from ._workspace_backend_operations import WorkspaceBackendOperations # type: ignore -from ._workspace_certificate_operations import WorkspaceCertificateOperations # type: ignore -from ._workspace_diagnostic_operations import WorkspaceDiagnosticOperations # type: ignore -from ._workspace_api_diagnostic_operations import WorkspaceApiDiagnosticOperations # type: ignore -from ._api_management_workspace_links_operations import ApiManagementWorkspaceLinksOperations # type: ignore -from ._api_management_workspace_link_operations import ApiManagementWorkspaceLinkOperations # type: ignore -from ._workspace_logger_operations import WorkspaceLoggerOperations # type: ignore -from ._workspace_operations import WorkspaceOperations # type: ignore -from ._workspace_policy_operations import WorkspacePolicyOperations # type: ignore -from ._workspace_named_value_operations import WorkspaceNamedValueOperations # type: ignore -from ._workspace_global_schema_operations import WorkspaceGlobalSchemaOperations # type: ignore -from ._workspace_notification_operations import WorkspaceNotificationOperations # type: ignore -from ._workspace_notification_recipient_user_operations import WorkspaceNotificationRecipientUserOperations # type: ignore -from ._workspace_notification_recipient_email_operations import WorkspaceNotificationRecipientEmailOperations # type: ignore -from ._workspace_policy_fragment_operations import WorkspacePolicyFragmentOperations # type: ignore -from ._workspace_group_operations import WorkspaceGroupOperations # type: ignore -from ._workspace_group_user_operations import WorkspaceGroupUserOperations # type: ignore -from ._workspace_subscription_operations import WorkspaceSubscriptionOperations # type: ignore -from ._workspace_api_version_set_operations import WorkspaceApiVersionSetOperations # type: ignore -from ._workspace_api_operations import WorkspaceApiOperations # type: ignore -from ._workspace_api_revision_operations import WorkspaceApiRevisionOperations # type: ignore -from ._workspace_api_release_operations import WorkspaceApiReleaseOperations # type: ignore -from ._workspace_api_operation_operations import WorkspaceApiOperationOperations # type: ignore -from ._workspace_api_operation_policy_operations import WorkspaceApiOperationPolicyOperations # type: ignore -from ._workspace_api_policy_operations import WorkspaceApiPolicyOperations # type: ignore -from ._workspace_api_schema_operations import WorkspaceApiSchemaOperations # type: ignore -from ._workspace_product_operations import WorkspaceProductOperations # type: ignore -from ._workspace_product_api_link_operations import WorkspaceProductApiLinkOperations # type: ignore -from ._workspace_product_group_link_operations import WorkspaceProductGroupLinkOperations # type: ignore -from ._workspace_product_policy_operations import WorkspaceProductPolicyOperations # type: ignore -from ._workspace_tag_operations import WorkspaceTagOperations # type: ignore -from ._workspace_tag_api_link_operations import WorkspaceTagApiLinkOperations # type: ignore -from ._workspace_tag_operation_link_operations import WorkspaceTagOperationLinkOperations # type: ignore -from ._workspace_tag_product_link_operations import WorkspaceTagProductLinkOperations # type: ignore -from ._workspace_api_export_operations import WorkspaceApiExportOperations # type: ignore -from ._operation_status_operations import OperationStatusOperations # type: ignore -from ._operations_results_operations import OperationsResultsOperations # type: ignore +from ._operations import WorkspaceApiOperations # type: ignore +from ._operations import WorkspaceApiReleaseOperations # type: ignore +from ._operations import WorkspaceApiOperationOperations # type: ignore +from ._operations import GraphQLApiResolverPolicyOperations # type: ignore +from ._operations import ApiPolicyOperations # type: ignore +from ._operations import PolicyOperations # type: ignore +from ._operations import ProductPolicyOperations # type: ignore +from ._operations import WorkspacePolicyOperations # type: ignore +from ._operations import WorkspaceApiOperationPolicyOperations # type: ignore +from ._operations import WorkspaceApiPolicyOperations # type: ignore +from ._operations import WorkspaceProductPolicyOperations # type: ignore +from ._operations import TagOperations # type: ignore +from ._operations import WorkspaceTagOperations # type: ignore +from ._operations import WorkspaceApiSchemaOperations # type: ignore +from ._operations import DiagnosticOperations # type: ignore +from ._operations import WorkspaceDiagnosticOperations # type: ignore +from ._operations import WorkspaceApiDiagnosticOperations # type: ignore +from ._operations import IssueOperations # type: ignore +from ._operations import ProductWikiOperations # type: ignore +from ._operations import WorkspaceApiVersionSetOperations # type: ignore +from ._operations import WorkspaceBackendOperations # type: ignore +from ._operations import WorkspaceCertificateOperations # type: ignore +from ._operations import WorkspaceGroupOperations # type: ignore +from ._operations import WorkspaceLoggerOperations # type: ignore +from ._operations import WorkspaceNamedValueOperations # type: ignore +from ._operations import WorkspaceNotificationOperations # type: ignore +from ._operations import WorkspacePolicyFragmentOperations # type: ignore +from ._operations import SignInSettingsOperations # type: ignore +from ._operations import SignUpSettingsOperations # type: ignore +from ._operations import DelegationSettingsOperations # type: ignore +from ._operations import WorkspaceProductOperations # type: ignore +from ._operations import WorkspaceProductApiLinkOperations # type: ignore +from ._operations import WorkspaceProductGroupLinkOperations # type: ignore +from ._operations import WorkspaceGlobalSchemaOperations # type: ignore +from ._operations import UserSubscriptionOperations # type: ignore +from ._operations import WorkspaceSubscriptionOperations # type: ignore +from ._operations import WorkspaceTagApiLinkOperations # type: ignore +from ._operations import WorkspaceTagOperationLinkOperations # type: ignore +from ._operations import WorkspaceTagProductLinkOperations # type: ignore +from ._operations import ApiManagementOperationsOperations # type: ignore +from ._operations import ApiGatewayOperations # type: ignore +from ._operations import ApiManagementGatewaySkusOperations # type: ignore +from ._operations import ApiOperations # type: ignore +from ._operations import ApiRevisionOperations # type: ignore +from ._operations import ApiProductOperations # type: ignore +from ._operations import OperationOperations # type: ignore +from ._operations import WorkspaceApiRevisionOperations # type: ignore +from ._operations import ApiManagementServiceOperations # type: ignore +from ._operations import AllPoliciesOperations # type: ignore +from ._operations import ApiManagementServiceSkusOperations # type: ignore +from ._operations import NetworkStatusOperations # type: ignore +from ._operations import OutboundNetworkDependenciesEndpointsOperations # type: ignore +from ._operations import PolicyDescriptionOperations # type: ignore +from ._operations import PolicyRestrictionValidationsOperations # type: ignore +from ._operations import PortalSettingsOperations # type: ignore +from ._operations import ProductOperations # type: ignore +from ._operations import QuotaByCounterKeysOperations # type: ignore +from ._operations import QuotaByPeriodKeysOperations # type: ignore +from ._operations import RegionOperations # type: ignore +from ._operations import ReportsOperations # type: ignore +from ._operations import TagResourceOperations # type: ignore +from ._operations import ApiReleaseOperations # type: ignore +from ._operations import ApiOperationOperations # type: ignore +from ._operations import ApiOperationPolicyOperations # type: ignore +from ._operations import GraphQLApiResolverOperations # type: ignore +from ._operations import ApiSchemaOperations # type: ignore +from ._operations import ApiDiagnosticOperations # type: ignore +from ._operations import ApiIssueOperations # type: ignore +from ._operations import ApiIssueCommentOperations # type: ignore +from ._operations import ApiIssueAttachmentOperations # type: ignore +from ._operations import ApiTagDescriptionOperations # type: ignore +from ._operations import ApiWikiOperations # type: ignore +from ._operations import ApiWikisOperations # type: ignore +from ._operations import ProductWikisOperations # type: ignore +from ._operations import ApiToolOperations # type: ignore +from ._operations import ApiVersionSetOperations # type: ignore +from ._operations import AuthorizationProviderOperations # type: ignore +from ._operations import AuthorizationOperations # type: ignore +from ._operations import AuthorizationLoginLinksOperations # type: ignore +from ._operations import AuthorizationAccessPolicyOperations # type: ignore +from ._operations import AuthorizationServerOperations # type: ignore +from ._operations import BackendOperations # type: ignore +from ._operations import CacheOperations # type: ignore +from ._operations import CertificateOperations # type: ignore +from ._operations import ContentTypeOperations # type: ignore +from ._operations import ContentItemOperations # type: ignore +from ._operations import DeletedServicesOperations # type: ignore +from ._operations import DocumentationOperations # type: ignore +from ._operations import EmailTemplateOperations # type: ignore +from ._operations import ApiGatewayConfigConnectionOperations # type: ignore +from ._operations import ApiGatewayHostnameBindingOperations # type: ignore +from ._operations import GatewayOperations # type: ignore +from ._operations import GatewayApiOperations # type: ignore +from ._operations import GatewayHostnameConfigurationOperations # type: ignore +from ._operations import GatewayCertificateAuthorityOperations # type: ignore +from ._operations import GroupOperations # type: ignore +from ._operations import GroupUserOperations # type: ignore +from ._operations import WorkspaceGroupUserOperations # type: ignore +from ._operations import IdentityProviderOperations # type: ignore +from ._operations import LoggerOperations # type: ignore +from ._operations import NamedValueOperations # type: ignore +from ._operations import NotificationOperations # type: ignore +from ._operations import NotificationRecipientUserOperations # type: ignore +from ._operations import NotificationRecipientEmailOperations # type: ignore +from ._operations import WorkspaceNotificationRecipientUserOperations # type: ignore +from ._operations import WorkspaceNotificationRecipientEmailOperations # type: ignore +from ._operations import OpenIdConnectProviderOperations # type: ignore +from ._operations import PolicyFragmentOperations # type: ignore +from ._operations import PolicyRestrictionOperations # type: ignore +from ._operations import PortalConfigOperations # type: ignore +from ._operations import ClientApplicationOperations # type: ignore +from ._operations import ClientApplicationProductLinkOperations # type: ignore +from ._operations import PortalRevisionOperations # type: ignore +from ._operations import PrivateEndpointConnectionOperations # type: ignore +from ._operations import ProductApiOperations # type: ignore +from ._operations import ProductGroupOperations # type: ignore +from ._operations import ProductSubscriptionsOperations # type: ignore +from ._operations import ProductApiLinkOperations # type: ignore +from ._operations import ProductGroupLinkOperations # type: ignore +from ._operations import GlobalSchemaOperations # type: ignore +from ._operations import TenantSettingsOperations # type: ignore +from ._operations import SubscriptionOperations # type: ignore +from ._operations import TagApiLinkOperations # type: ignore +from ._operations import TagOperationLinkOperations # type: ignore +from ._operations import TagProductLinkOperations # type: ignore +from ._operations import TenantAccessOperations # type: ignore +from ._operations import TenantAccessGitOperations # type: ignore +from ._operations import TenantConfigurationOperations # type: ignore +from ._operations import UserOperations # type: ignore +from ._operations import UserGroupOperations # type: ignore +from ._operations import UserIdentitiesOperations # type: ignore +from ._operations import UserConfirmationPasswordOperations # type: ignore +from ._operations import ApiManagementWorkspaceLinkOperations # type: ignore +from ._operations import ApiManagementWorkspaceLinksOperations # type: ignore +from ._operations import WorkspaceOperations # type: ignore +from ._operations import ApiExportOperations # type: ignore +from ._operations import ApiManagementSkusOperations # type: ignore +from ._operations import WorkspaceApiExportOperations # type: ignore +from ._operations import OperationStatusOperations # type: ignore +from ._operations import OperationsResultsOperations # type: ignore +from ._operations import _ApiManagementClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "WorkspaceApiOperations", + "WorkspaceApiReleaseOperations", + "WorkspaceApiOperationOperations", + "GraphQLApiResolverPolicyOperations", + "ApiPolicyOperations", + "PolicyOperations", + "ProductPolicyOperations", + "WorkspacePolicyOperations", + "WorkspaceApiOperationPolicyOperations", + "WorkspaceApiPolicyOperations", + "WorkspaceProductPolicyOperations", + "TagOperations", + "WorkspaceTagOperations", + "WorkspaceApiSchemaOperations", + "DiagnosticOperations", + "WorkspaceDiagnosticOperations", + "WorkspaceApiDiagnosticOperations", + "IssueOperations", + "ProductWikiOperations", + "WorkspaceApiVersionSetOperations", + "WorkspaceBackendOperations", + "WorkspaceCertificateOperations", + "WorkspaceGroupOperations", + "WorkspaceLoggerOperations", + "WorkspaceNamedValueOperations", + "WorkspaceNotificationOperations", + "WorkspacePolicyFragmentOperations", + "SignInSettingsOperations", + "SignUpSettingsOperations", + "DelegationSettingsOperations", + "WorkspaceProductOperations", + "WorkspaceProductApiLinkOperations", + "WorkspaceProductGroupLinkOperations", + "WorkspaceGlobalSchemaOperations", + "UserSubscriptionOperations", + "WorkspaceSubscriptionOperations", + "WorkspaceTagApiLinkOperations", + "WorkspaceTagOperationLinkOperations", + "WorkspaceTagProductLinkOperations", + "ApiManagementOperationsOperations", "ApiGatewayOperations", "ApiManagementGatewaySkusOperations", - "AllPoliciesOperations", "ApiOperations", "ApiRevisionOperations", + "ApiProductOperations", + "OperationOperations", + "WorkspaceApiRevisionOperations", + "ApiManagementServiceOperations", + "AllPoliciesOperations", + "ApiManagementServiceSkusOperations", + "NetworkStatusOperations", + "OutboundNetworkDependenciesEndpointsOperations", + "PolicyDescriptionOperations", + "PolicyRestrictionValidationsOperations", + "PortalSettingsOperations", + "ProductOperations", + "QuotaByCounterKeysOperations", + "QuotaByPeriodKeysOperations", + "RegionOperations", + "ReportsOperations", + "TagResourceOperations", "ApiReleaseOperations", "ApiOperationOperations", "ApiOperationPolicyOperations", - "TagOperations", "GraphQLApiResolverOperations", - "GraphQLApiResolverPolicyOperations", - "ApiProductOperations", - "ApiPolicyOperations", "ApiSchemaOperations", "ApiDiagnosticOperations", "ApiIssueOperations", "ApiIssueCommentOperations", "ApiIssueAttachmentOperations", "ApiTagDescriptionOperations", - "OperationOperations", "ApiWikiOperations", "ApiWikisOperations", - "ApiExportOperations", + "ProductWikisOperations", + "ApiToolOperations", "ApiVersionSetOperations", "AuthorizationProviderOperations", "AuthorizationOperations", @@ -187,63 +243,44 @@ "BackendOperations", "CacheOperations", "CertificateOperations", - "ApiManagementClientOperationsMixin", "ContentTypeOperations", "ContentItemOperations", "DeletedServicesOperations", - "ApiManagementOperationsOperations", - "ApiManagementServiceSkusOperations", - "ApiManagementServiceOperations", - "DiagnosticOperations", "DocumentationOperations", "EmailTemplateOperations", "ApiGatewayConfigConnectionOperations", + "ApiGatewayHostnameBindingOperations", "GatewayOperations", - "GatewayHostnameConfigurationOperations", "GatewayApiOperations", + "GatewayHostnameConfigurationOperations", "GatewayCertificateAuthorityOperations", "GroupOperations", "GroupUserOperations", + "WorkspaceGroupUserOperations", "IdentityProviderOperations", - "IssueOperations", "LoggerOperations", "NamedValueOperations", - "NetworkStatusOperations", "NotificationOperations", "NotificationRecipientUserOperations", "NotificationRecipientEmailOperations", + "WorkspaceNotificationRecipientUserOperations", + "WorkspaceNotificationRecipientEmailOperations", "OpenIdConnectProviderOperations", - "OutboundNetworkDependenciesEndpointsOperations", - "PolicyOperations", - "PolicyDescriptionOperations", "PolicyFragmentOperations", "PolicyRestrictionOperations", - "PolicyRestrictionValidationsOperations", "PortalConfigOperations", + "ClientApplicationOperations", + "ClientApplicationProductLinkOperations", "PortalRevisionOperations", - "PortalSettingsOperations", - "SignInSettingsOperations", - "SignUpSettingsOperations", - "DelegationSettingsOperations", "PrivateEndpointConnectionOperations", - "ProductOperations", "ProductApiOperations", "ProductGroupOperations", "ProductSubscriptionsOperations", - "ProductPolicyOperations", - "ProductWikiOperations", - "ProductWikisOperations", "ProductApiLinkOperations", "ProductGroupLinkOperations", - "QuotaByCounterKeysOperations", - "QuotaByPeriodKeysOperations", - "RegionOperations", - "ReportsOperations", "GlobalSchemaOperations", "TenantSettingsOperations", - "ApiManagementSkusOperations", "SubscriptionOperations", - "TagResourceOperations", "TagApiLinkOperations", "TagOperationLinkOperations", "TagProductLinkOperations", @@ -252,43 +289,13 @@ "TenantConfigurationOperations", "UserOperations", "UserGroupOperations", - "UserSubscriptionOperations", "UserIdentitiesOperations", "UserConfirmationPasswordOperations", - "WorkspaceBackendOperations", - "WorkspaceCertificateOperations", - "WorkspaceDiagnosticOperations", - "WorkspaceApiDiagnosticOperations", - "ApiManagementWorkspaceLinksOperations", "ApiManagementWorkspaceLinkOperations", - "WorkspaceLoggerOperations", + "ApiManagementWorkspaceLinksOperations", "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", + "ApiExportOperations", + "ApiManagementSkusOperations", "WorkspaceApiExportOperations", "OperationStatusOperations", "OperationsResultsOperations", 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 deleted file mode 100644 index 2790f4292610..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_all_policies_operations.py +++ /dev/null @@ -1,140 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 deleted file mode 100644 index 9881fd878d66..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py +++ /dev/null @@ -1,719 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._api_diagnostic_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiDiagnosticOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_service( - self, - resource_group_name: str, - service_name: 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - api_id: str, - diagnostic_id: str, - if_match: str, - parameters: _models.DiagnosticContract, - *, - 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 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.DiagnosticContract - :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, - 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 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, - api_id: str, - diagnostic_id: str, - if_match: str, - parameters: Union[_models.DiagnosticContract, 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 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 DiagnosticContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract 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 = { - 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_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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/_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py deleted file mode 100644 index 762c47cb71de..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py +++ /dev/null @@ -1,130 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiExportOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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. 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 - :return: ApiExportResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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/_api_gateway_config_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_config_connection_operations.py deleted file mode 100644 index 565bb3afbc55..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_config_connection_operations.py +++ /dev/null @@ -1,563 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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"]: - # pylint: disable=line-too-long - """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 = { - 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 = { - 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 = { - 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]: - # pylint: disable=line-too-long - """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]: - # pylint: disable=line-too-long - """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]: - # pylint: disable=line-too-long - """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": "azure-async-operation"}, **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 = { - 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 deleted file mode 100644 index 175669ee48ff..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_gateway_operations.py +++ /dev/null @@ -1,808 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 83c1f537a3f6..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py +++ /dev/null @@ -1,585 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._api_issue_attachment_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiIssueAttachmentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`api_issue_attachment` 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, - api_id: str, - issue_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.IssueAttachmentContract"]: - """Lists all attachments for the Issue associated with 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | - 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 IssueAttachmentContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentContract] - :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.IssueAttachmentCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_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("IssueAttachmentCollection", 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, api_id: str, issue_id: str, attachment_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the issue Attachment 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_id, - attachment_id=attachment_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, api_id: str, issue_id: str, attachment_id: str, **kwargs: Any - ) -> _models.IssueAttachmentContract: - """Gets the details of the issue Attachment 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_id: str - :return: IssueAttachmentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueAttachmentContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - attachment_id=attachment_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("IssueAttachmentContract", 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, - api_id: str, - issue_id: str, - attachment_id: str, - parameters: _models.IssueAttachmentContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueAttachmentContract: - """Creates a new Attachment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :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: IssueAttachmentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - attachment_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueAttachmentContract: - """Creates a new Attachment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_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: IssueAttachmentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - attachment_id: str, - parameters: Union[_models.IssueAttachmentContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.IssueAttachmentContract: - """Creates a new Attachment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_id: str - :param parameters: Create parameters. Is either a IssueAttachmentContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract 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: IssueAttachmentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueAttachmentContract] = 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, "IssueAttachmentContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - attachment_id=attachment_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("IssueAttachmentContract", 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( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - attachment_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the specified comment from an Issue. - - :param resource_group_name: The name of the resource group. The name is 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 identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_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 = { - 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, - api_id=api_id, - issue_id=issue_id, - attachment_id=attachment_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/_api_issue_comment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py deleted file mode 100644 index 25300c24057a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py +++ /dev/null @@ -1,585 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._api_issue_comment_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiIssueCommentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`api_issue_comment` 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, - api_id: str, - issue_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.IssueCommentContract"]: - """Lists all comments for the Issue associated with 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | - 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 IssueCommentContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueCommentContract] - :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.IssueCommentCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_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("IssueCommentCollection", 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, api_id: str, issue_id: str, comment_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the issue Comment 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_id, - comment_id=comment_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, api_id: str, issue_id: str, comment_id: str, **kwargs: Any - ) -> _models.IssueCommentContract: - """Gets the details of the issue Comment 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_id: str - :return: IssueCommentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueCommentContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - comment_id=comment_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("IssueCommentContract", 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, - api_id: str, - issue_id: str, - comment_id: str, - parameters: _models.IssueCommentContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueCommentContract: - """Creates a new Comment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract - :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: IssueCommentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - comment_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueCommentContract: - """Creates a new Comment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_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: IssueCommentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - comment_id: str, - parameters: Union[_models.IssueCommentContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.IssueCommentContract: - """Creates a new Comment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_id: str - :param parameters: Create parameters. Is either a IssueCommentContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract 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: IssueCommentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueCommentContract] = 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, "IssueCommentContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - comment_id=comment_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("IssueCommentContract", 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( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - comment_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the specified comment from an Issue. - - :param resource_group_name: The name of the resource group. The name is 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 identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_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 = { - 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, - api_id=api_id, - issue_id=issue_id, - comment_id=comment_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/_api_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py deleted file mode 100644 index efcfa6ba3635..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py +++ /dev/null @@ -1,732 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._api_issue_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiIssueOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`api_issue` 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, - api_id: str, - filter: Optional[str] = None, - expand_comments_attachments: Optional[bool] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.IssueContract"]: - """Lists all issues associated with 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 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 |
| userId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | - filter | eq | |
. Default value is None. - :type filter: str - :param expand_comments_attachments: Expand the comment attachments. Default value is None. - :type expand_comments_attachments: bool - :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 IssueContract or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueContract] - :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.IssueCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - api_id=api_id, - subscription_id=self._config.subscription_id, - filter=filter, - expand_comments_attachments=expand_comments_attachments, - 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("IssueCollection", 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, api_id: str, issue_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_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, - api_id: str, - issue_id: str, - expand_comments_attachments: Optional[bool] = None, - **kwargs: Any - ) -> _models.IssueContract: - """Gets the details of the Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param expand_comments_attachments: Expand the comment attachments. Default value is None. - :type expand_comments_attachments: bool - :return: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - subscription_id=self._config.subscription_id, - expand_comments_attachments=expand_comments_attachments, - 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("IssueContract", 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, - api_id: str, - issue_id: str, - parameters: _models.IssueContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueContract: - """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueContract - :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: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueContract: - """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - parameters: Union[_models.IssueContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.IssueContract: - """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param parameters: Create parameters. Is either a IssueContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueContract 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: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueContract] = 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, "IssueContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_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("IssueContract", 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, - api_id: str, - issue_id: str, - if_match: str, - parameters: _models.IssueUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueContract: - """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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.IssueUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueContract: - """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - if_match: str, - parameters: Union[_models.IssueUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.IssueContract: - """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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 IssueUpdateContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract or IO[bytes] - :return: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueContract] = 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, "IssueUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_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("IssueContract", 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( - self, resource_group_name: str, service_name: str, api_id: str, issue_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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 = { - 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, - api_id=api_id, - issue_id=issue_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/_api_management_client_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py deleted file mode 100644 index 189af14c47ab..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_client_operations.py +++ /dev/null @@ -1,249 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -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._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 -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 - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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(connectivity_check_request_params, (IOBase, bytes)): - _content = connectivity_check_request_params - else: - _json = self._serialize.body(connectivity_check_request_params, "ConnectivityCheckRequest") - - _request = build_perform_connectivity_check_async_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.url = self._client.format_url(_request.url) - - _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 - ) - - 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_perform_connectivity_check_async( - self, - resource_group_name: str, - service_name: str, - connectivity_check_request_params: _models.ConnectivityCheckRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ConnectivityCheckResponse]: - """Performs a connectivity check between the API Management service and a given destination, and - returns metrics for the connection, as well as errors encountered while trying to establish it. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param connectivity_check_request_params: Connectivity Check request parameters. Required. - :type connectivity_check_request_params: - ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest - :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 ConnectivityCheckResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_perform_connectivity_check_async( - self, - resource_group_name: str, - service_name: str, - connectivity_check_request_params: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ConnectivityCheckResponse]: - """Performs a connectivity check between the API Management service and a given destination, and - returns metrics for the connection, as well as errors encountered while trying to establish it. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param connectivity_check_request_params: Connectivity Check request parameters. Required. - :type connectivity_check_request_params: 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 ConnectivityCheckResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_perform_connectivity_check_async( - self, - resource_group_name: str, - service_name: str, - connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ConnectivityCheckResponse]: - """Performs a connectivity check between the API Management service and a given destination, and - returns metrics for the connection, as well as errors encountered while trying to establish it. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param connectivity_check_request_params: Connectivity Check request parameters. Is either a - ConnectivityCheckRequest type or a IO[bytes] type. Required. - :type connectivity_check_request_params: - ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ConnectivityCheckResponse or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] - :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.ConnectivityCheckResponse] = 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._perform_connectivity_check_async_initial( - resource_group_name=resource_group_name, - service_name=service_name, - connectivity_check_request_params=connectivity_check_request_params, - 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("ConnectivityCheckResponse", 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.ConnectivityCheckResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConnectivityCheckResponse]( - 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_management_gateway_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_gateway_skus_operations.py deleted file mode 100644 index d0c12f8ed75b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_gateway_skus_operations.py +++ /dev/null @@ -1,143 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 deleted file mode 100644 index 5eae2a76603a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py +++ /dev/null @@ -1,129 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_operations_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiManagementOperationsOperations: - """ - .. 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_operations` 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, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available REST API operations of the Microsoft.ApiManagement provider. - - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.Operation] - :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.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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( - 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("OperationListResult", 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_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py deleted file mode 100644 index 69a9bb21dd4e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py +++ /dev/null @@ -1,1879 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_management_service_operations import ( - build_apply_network_configuration_updates_request, - build_backup_request, - build_check_name_availability_request, - build_create_or_update_request, - build_delete_request, - build_get_domain_ownership_identifier_request, - build_get_request, - build_get_sso_token_request, - build_list_by_resource_group_request, - build_list_request, - build_migrate_to_stv2_request, - build_restore_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiManagementServiceOperations: - """ - .. 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_service` 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 _restore_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, "ApiManagementServiceBackupRestoreParameters") - - _request = build_restore_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.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_restore( - self, - resource_group_name: str, - service_name: str, - parameters: _models.ApiManagementServiceBackupRestoreParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Restores a backup of an API Management service created using the ApiManagementService_Backup - operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup - operation. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - :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_restore( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Restores a backup of an API Management service created using the ApiManagementService_Backup - operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup - 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 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_restore( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Restores a backup of an API Management service created using the ApiManagementService_Backup - operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup - operation. Is either a ApiManagementServiceBackupRestoreParameters type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - 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 = case_insensitive_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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._restore_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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _backup_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, "ApiManagementServiceBackupRestoreParameters") - - _request = build_backup_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.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_backup( - self, - resource_group_name: str, - service_name: str, - parameters: _models.ApiManagementServiceBackupRestoreParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - :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_backup( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup 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 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_backup( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Is either - a ApiManagementServiceBackupRestoreParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - 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 = case_insensitive_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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._backup_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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceResource, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, "ApiManagementServiceResource") - - _request = build_create_or_update_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.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, - service_name: str, - parameters: _models.ApiManagementServiceResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource - :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_create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service 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 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_create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceResource, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. - Is either a ApiManagementServiceResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource 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 = case_insensitive_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) - 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, - 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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, "ApiManagementServiceUpdateParameters") - - _request = build_update_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.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, - service_name: str, - parameters: _models.ApiManagementServiceUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters - :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_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service 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 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_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. - Is either a ApiManagementServiceUpdateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters 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 = case_insensitive_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) - 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, - 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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.ApiManagementServiceResource: - """Gets an API Management service 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 - :return: ApiManagementServiceResource or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ApiManagementServiceResource] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("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) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - 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, 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, service_name: str, **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Deletes an existing 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 - :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 {} - _params = 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_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("ApiManagementServiceResource", 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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _migrate_to_stv2_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Optional[Union[_models.MigrateToStv2Contract, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: - 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.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_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, - 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 - 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. 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 = case_insensitive_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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - 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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ApiManagementServiceResource]( - 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.ApiManagementServiceResource"]: - """List all API Management services 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 ApiManagementServiceResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :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.ApiManagementServiceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("ApiManagementServiceListResult", 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.ApiManagementServiceResource"]: - """Lists all API Management services within an Azure subscription. - - :return: An iterator like instance of either ApiManagementServiceResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :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.ApiManagementServiceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("ApiManagementServiceListResult", 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_sso_token( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.ApiManagementServiceGetSsoTokenResult: - """Gets the Single-Sign-On token for the API Management Service which is 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 - :return: ApiManagementServiceGetSsoTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ApiManagementServiceGetSsoTokenResult] = kwargs.pop("cls", None) - - _request = build_get_sso_token_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) - - _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("ApiManagementServiceGetSsoTokenResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def check_name_availability( - self, - parameters: _models.ApiManagementServiceCheckNameAvailabilityParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiManagementServiceNameAvailabilityResult: - """Checks availability and correctness of a name for an API Management service. - - :param parameters: Parameters supplied to the CheckNameAvailability operation. Required. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ApiManagementServiceNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ApiManagementServiceNameAvailabilityResult: - """Checks availability and correctness of a name for an API Management service. - - :param parameters: Parameters supplied to the CheckNameAvailability 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: ApiManagementServiceNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_name_availability( - self, parameters: Union[_models.ApiManagementServiceCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any - ) -> _models.ApiManagementServiceNameAvailabilityResult: - """Checks availability and correctness of a name for an API Management service. - - :param parameters: Parameters supplied to the CheckNameAvailability operation. Is either a - ApiManagementServiceCheckNameAvailabilityParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters or - IO[bytes] - :return: ApiManagementServiceNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ApiManagementServiceNameAvailabilityResult] = 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, "ApiManagementServiceCheckNameAvailabilityParameters") - - _request = build_check_name_availability_request( - 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("ApiManagementServiceNameAvailabilityResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_domain_ownership_identifier( - self, **kwargs: Any - ) -> _models.ApiManagementServiceGetDomainOwnershipIdentifierResult: - """Get the custom domain ownership identifier for an API Management service. - - :return: ApiManagementServiceGetDomainOwnershipIdentifierResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ApiManagementServiceGetDomainOwnershipIdentifierResult] = kwargs.pop("cls", None) - - _request = build_get_domain_ownership_identifier_request( - 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( - "ApiManagementServiceGetDomainOwnershipIdentifierResult", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _apply_network_configuration_updates_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - service_name: str, - parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: - if parameters is not None: - _json = self._serialize.body(parameters, "ApiManagementServiceApplyNetworkConfigurationParameters") - else: - _json = None - - _request = build_apply_network_configuration_updates_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.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_apply_network_configuration_updates( # pylint: disable=name-too-long - self, - resource_group_name: str, - service_name: str, - parameters: Optional[_models.ApiManagementServiceApplyNetworkConfigurationParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated - DNS changes. - - :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the - parameters are empty, all the regions in which the Api Management service is deployed will be - updated sequentially without incurring downtime in the region. Default value is None. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters - :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_apply_network_configuration_updates( # pylint: disable=name-too-long - self, - resource_group_name: str, - service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated - DNS changes. - - :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the - parameters are empty, all the regions in which the Api Management service is deployed will be - updated sequentially without incurring downtime in the region. 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_apply_network_configuration_updates( # pylint: disable=name-too-long - self, - resource_group_name: str, - service_name: str, - parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: - """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated - DNS changes. - - :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the - parameters are empty, all the regions in which the Api Management service is deployed will be - updated sequentially without incurring downtime in the region. Is either a - ApiManagementServiceApplyNetworkConfigurationParameters type or a IO[bytes] type. Default value - is None. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters 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 = case_insensitive_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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._apply_network_configuration_updates_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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ApiManagementServiceResource]( - 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_management_service_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py deleted file mode 100644 index 39f51d8ad742..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py +++ /dev/null @@ -1,142 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_service_skus_operations import build_list_available_service_skus_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiManagementServiceSkusOperations: - """ - .. 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_service_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_service_skus( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceSkuResult"]: - """Gets available SKUs for API Management service. - - Gets all available SKU for a given 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 - :return: An iterator like instance of either ResourceSkuResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResult] - :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.ResourceSkuResults] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_service_skus_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("ResourceSkuResults", 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_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py deleted file mode 100644 index 9ce0ebd79619..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_skus_operations.py +++ /dev/null @@ -1,131 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_skus_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiManagementSkusOperations: - """ - .. 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_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(self, **kwargs: Any) -> AsyncIterable["_models.ApiManagementSku"]: - """Gets the list of Microsoft.ApiManagement SKUs available for your Subscription. - - :return: An iterator like instance of either ApiManagementSku or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSku] - :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.ApiManagementSkusResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("ApiManagementSkusResult", 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_workspace_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_link_operations.py deleted file mode 100644 index b4e0aa89a2b5..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_link_operations.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 deleted file mode 100644 index 9aa6b9d0732b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_workspace_links_operations.py +++ /dev/null @@ -1,141 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 deleted file mode 100644 index ac020ef67700..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py +++ /dev/null @@ -1,727 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiOperationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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/_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py deleted file mode 100644 index 5b6f8fe5229e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py +++ /dev/null @@ -1,543 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiOperationPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_async - async def list_by_operation( - self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, **kwargs: Any - ) -> _models.PolicyCollection: - """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 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: PolicyCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, - resource_group_name: str, - service_name: 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 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 = { - 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, - 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/_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py deleted file mode 100644 index cba9f10016f4..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py +++ /dev/null @@ -1,964 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_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_by_tags_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - api_id: str, - parameters: Union[_models.ApiCreateOrUpdateParameter, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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 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, - 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 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 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, - 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 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 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, - 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, - api_id: str, - if_match: str, - parameters: _models.ApiUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiContract: - """Updates 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 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, - api_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiContract: - """Updates 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 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, - api_id: str, - if_match: str, - parameters: Union[_models.ApiUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.ApiContract: - """Updates 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 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 = { - 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, - 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 - - async def _delete_initial( - self, - resource_group_name: str, - service_name: str, - api_id: str, - if_match: str, - delete_revisions: Optional[bool] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - service_name=service_name, - 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) - - _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")) - 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_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( - self, - resource_group_name: str, - service_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - include_not_tagged_apis: Optional[bool] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TagResourceContract"]: - """Lists a collection of apis associated with tags. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| - displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| path | 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 |
| isCurrent | 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 - :param include_not_tagged_apis: Include not tagged APIs. Default value is None. - :type include_not_tagged_apis: bool - :return: An iterator like instance of either TagResourceContract or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :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.TagResourceCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_tags_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - include_not_tagged_apis=include_not_tagged_apis, - 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("TagResourceCollection", 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_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py deleted file mode 100644 index 58eeade32347..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py +++ /dev/null @@ -1,511 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_async - async def list_by_api( - self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any - ) -> _models.PolicyCollection: - """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 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: PolicyCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, 200]: - map_error(status_code=response.status_code, 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, - resource_group_name: str, - service_name: 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 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 = { - 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, - 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/_api_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py deleted file mode 100644 index 2d79dfc3e08a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py +++ /dev/null @@ -1,163 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_product_operations import build_list_by_apis_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiProductOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`api_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_apis( - self, - resource_group_name: str, - service_name: str, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ProductContract"]: - """Lists all Products, which the API is part of. - - :param resource_group_name: The name of the resource group. The name is 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 identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| 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 - :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 = { - 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_apis_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("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) 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 deleted file mode 100644 index 1bbb5a632234..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py +++ /dev/null @@ -1,721 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiReleaseOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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/_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py deleted file mode 100644 index dcec88bc096d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py +++ /dev/null @@ -1,163 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiRevisionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py deleted file mode 100644 index e45336e46911..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py +++ /dev/null @@ -1,642 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiSchemaOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - api_id: str, - schema_id: str, - parameters: Union[_models.SchemaContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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, - 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 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, - 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 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, - 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( - self, - resource_group_name: str, - service_name: 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 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 = { - 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, - 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/_api_tag_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py deleted file mode 100644 index b371ccf2ec5b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py +++ /dev/null @@ -1,554 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._api_tag_description_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiTagDescriptionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`api_tag_description` 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, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TagDescriptionContract"]: - """Lists all Tags descriptions in scope of API. Model similar to swagger - tagDescription is - defined on API level but tag may be assigned to the Operations. - - :param resource_group_name: The name of the resource group. The name is 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| 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 TagDescriptionContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionContract] - :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.TagDescriptionCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("TagDescriptionCollection", 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, api_id: str, tag_description_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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - tag_description_id=tag_description_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, api_id: str, tag_description_id: str, **kwargs: Any - ) -> _models.TagDescriptionContract: - """Get Tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_id: str - :return: TagDescriptionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.TagDescriptionContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - tag_description_id=tag_description_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("TagDescriptionContract", 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, - api_id: str, - tag_description_id: str, - parameters: _models.TagDescriptionCreateParameters, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TagDescriptionContract: - """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters - :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: TagDescriptionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - tag_description_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TagDescriptionContract: - """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_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: TagDescriptionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - tag_description_id: str, - parameters: Union[_models.TagDescriptionCreateParameters, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.TagDescriptionContract: - """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_id: str - :param parameters: Create parameters. Is either a TagDescriptionCreateParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters 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: TagDescriptionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.TagDescriptionContract] = 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, "TagDescriptionCreateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - tag_description_id=tag_description_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("TagDescriptionContract", 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( - self, - resource_group_name: str, - service_name: str, - api_id: str, - tag_description_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Delete tag description 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_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 = { - 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, - api_id=api_id, - tag_description_id=tag_description_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/_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py deleted file mode 100644 index 29a0b39a5f8a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiVersionSetOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 |
|-------------|-------------|-------------|-------------|
. 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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/_api_wiki_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wiki_operations.py deleted file mode 100644 index 66514ebb2e91..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wiki_operations.py +++ /dev/null @@ -1,567 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._api_wiki_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_entity_tag_request, - build_get_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiWikiOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`api_wiki` 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_entity_tag(self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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, api_id: str, **kwargs: Any - ) -> _models.WikiContract: - """Gets the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("WikiContract", 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, - api_id: str, - parameters: _models.WikiContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiContract - :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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - parameters: Union[_models.WikiContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: Create parameters. Is either a WikiContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiContract 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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = 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, "WikiContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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, 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("WikiContract", 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, - api_id: str, - if_match: str, - parameters: _models.WikiUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - 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: Wiki Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - 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: Wiki 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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - if_match: str, - parameters: Union[_models.WikiUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - 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: Wiki Update parameters. Is either a WikiUpdateContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract or IO[bytes] - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = 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, "WikiUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("WikiContract", 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( - self, resource_group_name: str, service_name: str, api_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_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/_api_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wikis_operations.py deleted file mode 100644 index 9ad0dd4ad9e0..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_wikis_operations.py +++ /dev/null @@ -1,161 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_wikis_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ApiWikisOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`api_wikis` 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, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.WikiContract"]: - """Gets the wikis 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 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 | eq | contains |
. 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 WikiContract or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.WikiContract] - :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.WikiCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("WikiCollection", 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/_authorization_access_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_access_policy_operations.py deleted file mode 100644 index 06ee014074c4..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_access_policy_operations.py +++ /dev/null @@ -1,503 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._authorization_access_policy_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_authorization_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AuthorizationAccessPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`authorization_access_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_authorization( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.AuthorizationAccessPolicyContract"]: - """Lists a collection of authorization access policy defined within a authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_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 - :return: An iterator like instance of either AuthorizationAccessPolicyContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract] - :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.AuthorizationAccessPolicyCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_authorization_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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("AuthorizationAccessPolicyCollection", 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, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - **kwargs: Any - ) -> _models.AuthorizationAccessPolicyContract: - """Gets the details of the authorization access 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 authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_id: str - :return: AuthorizationAccessPolicyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationAccessPolicyContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_id, - authorization_access_policy_id=authorization_access_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")) - - deserialized = self._deserialize("AuthorizationAccessPolicyContract", 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, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - parameters: _models.AuthorizationAccessPolicyContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationAccessPolicyContract: - """Creates or updates Authorization Access Policy. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :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: AuthorizationAccessPolicyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationAccessPolicyContract: - """Creates or updates Authorization Access Policy. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_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: AuthorizationAccessPolicyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - parameters: Union[_models.AuthorizationAccessPolicyContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.AuthorizationAccessPolicyContract: - """Creates or updates Authorization Access Policy. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_id: str - :param parameters: Create parameters. Is either a AuthorizationAccessPolicyContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract 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: AuthorizationAccessPolicyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationAccessPolicyContract] = 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, "AuthorizationAccessPolicyContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_id, - authorization_access_policy_id=authorization_access_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("AuthorizationAccessPolicyContract", 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( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Deletes specific access policy from the Authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_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 = { - 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, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_id, - authorization_access_policy_id=authorization_access_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/_authorization_login_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_login_links_operations.py deleted file mode 100644 index c6e9f677ae55..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_login_links_operations.py +++ /dev/null @@ -1,209 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._authorization_login_links_operations import build_post_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AuthorizationLoginLinksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`authorization_login_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") - - @overload - async def post( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: _models.AuthorizationLoginRequestContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationLoginResponseContract: - """Gets authorization login links. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AuthorizationLoginResponseContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def post( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationLoginResponseContract: - """Gets authorization login links. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create 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: AuthorizationLoginResponseContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def post( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: Union[_models.AuthorizationLoginRequestContract, IO[bytes]], - **kwargs: Any - ) -> _models.AuthorizationLoginResponseContract: - """Gets authorization login links. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Is either a AuthorizationLoginRequestContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract or - IO[bytes] - :return: AuthorizationLoginResponseContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationLoginResponseContract] = 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, "AuthorizationLoginRequestContract") - - _request = build_post_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationLoginResponseContract", 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/_authorization_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_operations.py deleted file mode 100644 index 1f2b8ad8c689..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_operations.py +++ /dev/null @@ -1,633 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._authorization_operations import ( - build_confirm_consent_code_request, - build_create_or_update_request, - build_delete_request, - build_get_request, - build_list_by_authorization_provider_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AuthorizationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`authorization` 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_authorization_provider( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.AuthorizationContract"]: - """Lists a collection of authorization providers defined within a authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_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 - :return: An iterator like instance of either AuthorizationContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationContract] - :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.AuthorizationCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_authorization_provider_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_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("AuthorizationCollection", 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, - authorization_provider_id: str, - authorization_id: str, - **kwargs: Any - ) -> _models.AuthorizationContract: - """Gets the details of the authorization 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 authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :return: AuthorizationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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("AuthorizationContract", 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, - authorization_provider_id: str, - authorization_id: str, - parameters: _models.AuthorizationContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationContract: - """Creates or updates authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract - :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: AuthorizationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationContract: - """Creates or updates authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_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: AuthorizationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: Union[_models.AuthorizationContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.AuthorizationContract: - """Creates or updates authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Is either a AuthorizationContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract 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: AuthorizationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationContract] = 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, "AuthorizationContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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("AuthorizationContract", 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( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Deletes specific Authorization from the Authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_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 = { - 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, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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 - - @overload - async def confirm_consent_code( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: _models.AuthorizationConfirmConsentCodeRequestContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Confirm valid consent code to suppress Authorizations anti-phishing page. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Required. - :type parameters: - ~azure.mgmt.apimanagement.models.AuthorizationConfirmConsentCodeRequestContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def confirm_consent_code( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Confirm valid consent code to suppress Authorizations anti-phishing page. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def confirm_consent_code( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: Union[_models.AuthorizationConfirmConsentCodeRequestContract, IO[bytes]], - **kwargs: Any - ) -> None: - """Confirm valid consent code to suppress Authorizations anti-phishing page. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Is either a - AuthorizationConfirmConsentCodeRequestContract type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.apimanagement.models.AuthorizationConfirmConsentCodeRequestContract or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "AuthorizationConfirmConsentCodeRequestContract") - - _request = build_confirm_consent_code_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore 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 deleted file mode 100644 index 5719a1eb32c8..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_provider_operations.py +++ /dev/null @@ -1,449 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._authorization_provider_operations import ( - build_create_or_update_request, - build_delete_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AuthorizationProviderOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`authorization_provider` 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.AuthorizationProviderContract"]: - """Lists a collection of authorization providers 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 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 - :return: An iterator like instance of either AuthorizationProviderContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationProviderContract] - :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.AuthorizationProviderCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("AuthorizationProviderCollection", 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, authorization_provider_id: str, **kwargs: Any - ) -> _models.AuthorizationProviderContract: - """Gets the details of the authorization provider 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 authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :return: AuthorizationProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationProviderContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_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("AuthorizationProviderContract", 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, - authorization_provider_id: str, - parameters: _models.AuthorizationProviderContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationProviderContract: - """Creates or updates authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :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: AuthorizationProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationProviderContract: - """Creates or updates authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_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: AuthorizationProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - parameters: Union[_models.AuthorizationProviderContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.AuthorizationProviderContract: - """Creates or updates authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param parameters: Create parameters. Is either a AuthorizationProviderContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract 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: AuthorizationProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationProviderContract] = 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, "AuthorizationProviderContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_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("AuthorizationProviderContract", 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( - self, resource_group_name: str, service_name: str, authorization_provider_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific authorization provider from 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 authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_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 = { - 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, - authorization_provider_id=authorization_provider_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/_authorization_server_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py deleted file mode 100644 index f762a29d30ae..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py +++ /dev/null @@ -1,733 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._authorization_server_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_secrets_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class AuthorizationServerOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`authorization_server` 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.AuthorizationServerContract"]: - """Lists a collection of authorization servers 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 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 - :return: An iterator like instance of either AuthorizationServerContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerContract] - :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.AuthorizationServerCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("AuthorizationServerCollection", 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, authsid: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the authorizationServer 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 authsid: Identifier of the authorization server. Required. - :type authsid: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - authsid=authsid, - 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, authsid: str, **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Gets the details of the authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: str - :return: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationServerContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - authsid=authsid, - 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("AuthorizationServerContract", 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, - authsid: str, - parameters: _models.AuthorizationServerContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Creates new authorization server or updates an existing authorization server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authsid: Identifier of the authorization server. Required. - :type authsid: str - :param parameters: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :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: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - authsid: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Creates new authorization server or updates an existing authorization server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authsid: Identifier of the authorization server. Required. - :type authsid: 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: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - authsid: str, - parameters: Union[_models.AuthorizationServerContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Creates new authorization server or updates an existing authorization server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authsid: Identifier of the authorization server. Required. - :type authsid: str - :param parameters: Create or update parameters. Is either a AuthorizationServerContract type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract 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: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationServerContract] = 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, "AuthorizationServerContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authsid=authsid, - 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("AuthorizationServerContract", 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, - authsid: str, - if_match: str, - parameters: _models.AuthorizationServerUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: 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: OAuth2 Server settings Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - authsid: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: 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: OAuth2 Server settings 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: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - authsid: str, - if_match: str, - parameters: Union[_models.AuthorizationServerUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: 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: OAuth2 Server settings Update parameters. Is either a - AuthorizationServerUpdateContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract or - IO[bytes] - :return: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationServerContract] = 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, "AuthorizationServerUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authsid=authsid, - 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("AuthorizationServerContract", 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( - self, resource_group_name: str, service_name: str, authsid: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: 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 = { - 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, - authsid=authsid, - 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_secrets( - self, resource_group_name: str, service_name: str, authsid: str, **kwargs: Any - ) -> _models.AuthorizationServerSecretsContract: - """Gets the client secret details of the authorization server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authsid: Identifier of the authorization server. Required. - :type authsid: str - :return: AuthorizationServerSecretsContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationServerSecretsContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_request( - resource_group_name=resource_group_name, - service_name=service_name, - authsid=authsid, - 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("AuthorizationServerSecretsContract", 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/_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py deleted file mode 100644 index fe358714eee4..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py +++ /dev/null @@ -1,823 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._backend_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_entity_tag_request, - build_get_request, - build_list_by_service_request, - build_reconnect_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class BackendOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_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.BackendContract"]: - """Lists a collection of backends in the specified 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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 - - @overload - async def reconnect( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - parameters: Optional[_models.BackendReconnectContract] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Notifies the API Management gateway to create a new connection to the backend after the - specified timeout. If no timeout was specified, timeout of 2 minutes is used. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: 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: Reconnect request parameters. Default value is None. - :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def reconnect( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Notifies the API Management gateway to create a new connection to the backend after the - specified timeout. If no timeout was specified, timeout of 2 minutes is used. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: 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: Reconnect request parameters. 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def reconnect( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - parameters: Optional[Union[_models.BackendReconnectContract, IO[bytes]]] = None, - **kwargs: Any - ) -> None: - """Notifies the API Management gateway to create a new connection to the backend after the - specified timeout. If no timeout was specified, timeout of 2 minutes is used. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: 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: Reconnect request parameters. Is either a BackendReconnectContract type or a - IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "BackendReconnectContract") - else: - _json = None - - _request = build_reconnect_request( - resource_group_name=resource_group_name, - service_name=service_name, - backend_id=backend_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 [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) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore 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 deleted file mode 100644 index 845f97fac892..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py +++ /dev/null @@ -1,675 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._cache_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CacheOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`cache` 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, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.CacheContract"]: - """Lists a collection of all external Caches in the specified 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 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 CacheContract or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CacheContract] - :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.CacheCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("CacheCollection", 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, cache_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - cache_id=cache_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, cache_id: str, **kwargs: Any - ) -> _models.CacheContract: - """Gets the details of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_id: str - :return: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.CacheContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - cache_id=cache_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("CacheContract", 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, - cache_id: str, - parameters: _models.CacheContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CacheContract: - """Creates or updates an External Cache to be used in Api Management instance. - - .. seealso:: - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-cache-external - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_id: str - :param parameters: Create or Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.CacheContract - :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: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CacheContract: - """Creates or updates an External Cache to be used in Api Management instance. - - .. seealso:: - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-cache-external - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - parameters: Union[_models.CacheContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.CacheContract: - """Creates or updates an External Cache to be used in Api Management instance. - - .. seealso:: - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-cache-external - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_id: str - :param parameters: Create or Update parameters. Is either a CacheContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.CacheContract 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: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.CacheContract] = 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, "CacheContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - cache_id=cache_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("CacheContract", 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, - cache_id: str, - if_match: str, - parameters: _models.CacheUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CacheContract: - """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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.CacheUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CacheContract: - """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - if_match: str, - parameters: Union[_models.CacheUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.CacheContract: - """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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 CacheUpdateParameters type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters or IO[bytes] - :return: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.CacheContract] = 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, "CacheUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - cache_id=cache_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("CacheContract", 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( - self, resource_group_name: str, service_name: str, cache_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific Cache. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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 = { - 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, - cache_id=cache_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/_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py deleted file mode 100644 index c36e9ba4046f..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py +++ /dev/null @@ -1,605 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._certificate_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_entity_tag_request, - build_get_request, - build_list_by_service_request, - build_refresh_secret_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class CertificateOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_service( - self, - resource_group_name: str, - service_name: 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 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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, 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 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 = { - 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, - 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/_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py deleted file mode 100644 index 13aff7d8c64b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_item_operations.py +++ /dev/null @@ -1,520 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._content_item_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ContentItemOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`content_item` 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, content_type_id: str, **kwargs: Any - ) -> AsyncIterable["_models.ContentItemContract"]: - """Lists developer portal's content items specified by the provided content type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :return: An iterator like instance of either ContentItemContract or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentItemContract] - :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.ContentItemCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - content_type_id=content_type_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("ContentItemCollection", 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, content_type_id: str, content_item_id: str, **kwargs: Any - ) -> bool: - """Returns the entity state (ETag) version of the developer portal's content item 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 content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - content_type_id=content_type_id, - content_item_id=content_item_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, content_type_id: str, content_item_id: str, **kwargs: Any - ) -> _models.ContentItemContract: - """Returns the developer portal's content item 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 content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_id: str - :return: ContentItemContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ContentItemContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - content_type_id=content_type_id, - content_item_id=content_item_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("ContentItemContract", 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, - content_type_id: str, - content_item_id: str, - parameters: _models.ContentItemContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ContentItemContract: - """Creates a new developer portal's content item specified by the provided content type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_id: str - :param parameters: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ContentItemContract - :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: ContentItemContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - content_item_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ContentItemContract: - """Creates a new developer portal's content item specified by the provided content type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_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: ContentItemContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - content_item_id: str, - parameters: Union[_models.ContentItemContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.ContentItemContract: - """Creates a new developer portal's content item specified by the provided content type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_id: str - :param parameters: Create or update parameters. Is either a ContentItemContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ContentItemContract 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: ContentItemContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ContentItemContract] = 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, "ContentItemContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - content_type_id=content_type_id, - content_item_id=content_item_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("ContentItemContract", 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( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - content_item_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Removes the specified developer portal's content item. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_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 = { - 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, - content_type_id=content_type_id, - content_item_id=content_item_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/_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py deleted file mode 100644 index f96fe5d0409d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py +++ /dev/null @@ -1,439 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._content_type_operations import ( - build_create_or_update_request, - build_delete_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ContentTypeOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`content_type` 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.ContentTypeContract"]: - """Lists the developer portal's content types. Content types describe content items' properties, - validation rules, and constraints. - - :param resource_group_name: The name of the resource group. The name 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 ContentTypeContract or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentTypeContract] - :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.ContentTypeCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("ContentTypeCollection", 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, content_type_id: str, **kwargs: Any - ) -> _models.ContentTypeContract: - """Gets the details of the developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :return: ContentTypeContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ContentTypeContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - content_type_id=content_type_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("ContentTypeContract", 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, - content_type_id: str, - parameters: _models.ContentTypeContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ContentTypeContract: - """Creates or updates the developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. Custom content types' identifiers need to start - with the ``c-`` prefix. Built-in content types can't be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param parameters: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract - :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: ContentTypeContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ContentTypeContract: - """Creates or updates the developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. Custom content types' identifiers need to start - with the ``c-`` prefix. Built-in content types can't be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_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: ContentTypeContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - parameters: Union[_models.ContentTypeContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.ContentTypeContract: - """Creates or updates the developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. Custom content types' identifiers need to start - with the ``c-`` prefix. Built-in content types can't be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param parameters: Create or update parameters. Is either a ContentTypeContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract 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: ContentTypeContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ContentTypeContract] = 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, "ContentTypeContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - content_type_id=content_type_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("ContentTypeContract", 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( - self, resource_group_name: str, service_name: str, content_type_id: str, if_match: str, **kwargs: Any - ) -> None: - """Removes the specified developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. Built-in content types (with identifiers - starting with the ``c-`` prefix) can't be removed. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_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 = { - 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, - content_type_id=content_type_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/_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py deleted file mode 100644 index 45313c9ac26f..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py +++ /dev/null @@ -1,517 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._delegation_settings_operations import ( - build_create_or_update_request, - build_get_entity_tag_request, - build_get_request, - build_list_secrets_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DelegationSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`delegation_settings` 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_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the DelegationSettings. - - :param resource_group_name: The name of the resource group. The name 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: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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, **kwargs: Any) -> _models.PortalDelegationSettings: - """Get Delegation Settings for the Portal. - - :param resource_group_name: The name of the resource group. The name 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: PortalDelegationSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalDelegationSettings] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("PortalDelegationSettings", 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, - if_match: str, - parameters: _models.PortalDelegationSettings, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Delegation settings. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Delegation settings. 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: Union[_models.PortalDelegationSettings, IO[bytes]], - **kwargs: Any - ) -> None: - """Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Delegation settings. Is either a PortalDelegationSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "PortalDelegationSettings") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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 [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 create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: _models.PortalDelegationSettings, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalDelegationSettings: - """Create or Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :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: PortalDelegationSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalDelegationSettings: - """Create or Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is 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: 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: PortalDelegationSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.PortalDelegationSettings, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.PortalDelegationSettings: - """Create or Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is either a PortalDelegationSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings 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: PortalDelegationSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalDelegationSettings] = 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, "PortalDelegationSettings") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - deserialized = self._deserialize("PortalDelegationSettings", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list_secrets( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.PortalSettingValidationKeyContract: - """Gets the secret validation key of the DelegationSettings. - - :param resource_group_name: The name of the resource group. The name 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: PortalSettingValidationKeyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSettingValidationKeyContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_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) - - _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("PortalSettingValidationKeyContract", 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/_deleted_services_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py deleted file mode 100644 index 9e65b1b506af..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py +++ /dev/null @@ -1,315 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast -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._deleted_services_operations import ( - build_get_by_name_request, - build_list_by_subscription_request, - build_purge_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DeletedServicesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`deleted_services` 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_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DeletedServiceContract"]: - """Lists all soft-deleted services available for undelete for the given subscription. - - :return: An iterator like instance of either DeletedServiceContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DeletedServiceContract] - :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.DeletedServicesCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_subscription_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("DeletedServicesCollection", 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_by_name(self, service_name: str, location: str, **kwargs: Any) -> _models.DeletedServiceContract: - """Get soft-deleted Api Management Service by name. - - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param location: The location of the deleted API Management service. Required. - :type location: str - :return: DeletedServiceContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.DeletedServiceContract] = kwargs.pop("cls", None) - - _request = build_get_by_name_request( - service_name=service_name, - location=location, - 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("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) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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_purge_request( - service_name=service_name, - location=location, - 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, 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_purge( - self, service_name: str, location: str, **kwargs: Any - ) -> AsyncLROPoller[_models.DeletedServiceContract]: - """Purges Api Management Service (deletes it with no option to undelete). - - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param location: The location of the deleted API Management service. Required. - :type location: str - :return: An instance of AsyncLROPoller that returns either DeletedServiceContract or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] - :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._purge_initial( - service_name=service_name, - location=location, - 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("DeletedServiceContract", 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.DeletedServiceContract].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.DeletedServiceContract]( - 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/_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py deleted file mode 100644 index 896fa136079f..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._diagnostic_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DiagnosticOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_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.DiagnosticContract"]: - """Lists all diagnostics 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - diagnostic_id: str, - if_match: str, - parameters: _models.DiagnosticContract, - *, - 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 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.DiagnosticContract - :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, - 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 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, - diagnostic_id: str, - if_match: str, - parameters: Union[_models.DiagnosticContract, 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 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 DiagnosticContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract 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 = { - 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_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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/_documentation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_documentation_operations.py deleted file mode 100644 index 30d773c25067..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_documentation_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._documentation_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class DocumentationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`documentation` 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.DocumentationContract"]: - """Lists all Documentations 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | eq | contains |
. 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 DocumentationContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DocumentationContract] - :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.DocumentationCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("DocumentationCollection", 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, documentation_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - documentation_id=documentation_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, documentation_id: str, **kwargs: Any - ) -> _models.DocumentationContract: - """Gets the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_id: str - :return: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.DocumentationContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - documentation_id=documentation_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("DocumentationContract", 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, - documentation_id: str, - parameters: _models.DocumentationContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DocumentationContract: - """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DocumentationContract - :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: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - documentation_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DocumentationContract: - """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - documentation_id: str, - parameters: Union[_models.DocumentationContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.DocumentationContract: - """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_id: str - :param parameters: Create parameters. Is either a DocumentationContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DocumentationContract 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: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.DocumentationContract] = 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, "DocumentationContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - documentation_id=documentation_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("DocumentationContract", 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, - documentation_id: str, - if_match: str, - parameters: _models.DocumentationUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DocumentationContract: - """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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: Documentation Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DocumentationUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - documentation_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DocumentationContract: - """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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: Documentation 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: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - documentation_id: str, - if_match: str, - parameters: Union[_models.DocumentationUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.DocumentationContract: - """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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: Documentation Update parameters. Is either a DocumentationUpdateContract - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DocumentationUpdateContract or IO[bytes] - :return: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.DocumentationContract] = 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, "DocumentationUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - documentation_id=documentation_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("DocumentationContract", 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( - self, resource_group_name: str, service_name: str, documentation_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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 = { - 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, - documentation_id=documentation_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/_email_template_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py deleted file mode 100644 index 5ab26ebe965c..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py +++ /dev/null @@ -1,741 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._email_template_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class EmailTemplateOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`email_template` 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.EmailTemplateContract"]: - """Gets all email templates. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| 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 EmailTemplateContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateContract] - :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.EmailTemplateCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("EmailTemplateCollection", 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, - template_name: Union[str, _models.TemplateName], - **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the email template 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 template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - template_name=template_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) - - 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, - template_name: Union[str, _models.TemplateName], - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Gets the details of the email template 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 template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :return: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.EmailTemplateContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - template_name=template_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("EmailTemplateContract", 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, - template_name: Union[str, _models.TemplateName], - parameters: _models.EmailTemplateUpdateParameters, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates an Email Template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :param parameters: Email Template update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters - :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: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates an Email Template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :param parameters: Email Template 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: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - parameters: Union[_models.EmailTemplateUpdateParameters, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates an Email Template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :param parameters: Email Template update parameters. Is either a EmailTemplateUpdateParameters - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters 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: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.EmailTemplateContract] = 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, "EmailTemplateUpdateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - template_name=template_name, - 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) - - deserialized = self._deserialize("EmailTemplateContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - if_match: str, - parameters: _models.EmailTemplateUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates API Management email template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :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.EmailTemplateUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates API Management email template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :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: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - if_match: str, - parameters: Union[_models.EmailTemplateUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates API Management email template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :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 EmailTemplateUpdateParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or IO[bytes] - :return: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.EmailTemplateContract] = 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, "EmailTemplateUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - template_name=template_name, - 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("EmailTemplateContract", 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( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - if_match: str, - **kwargs: Any - ) -> None: - """Reset the Email Template to default template provided by 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 template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :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 = { - 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, - template_name=template_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, 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/_gateway_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py deleted file mode 100644 index ffc8f89bf547..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py +++ /dev/null @@ -1,457 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._gateway_api_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_entity_tag_request, - build_list_by_service_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GatewayApiOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`gateway_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, - gateway_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ApiContract"]: - """Lists a collection of the APIs associated with a 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 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 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 = { - 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, - gateway_id=gateway_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("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, gateway_id: str, api_id: str, **kwargs: Any - ) -> bool: - """Checks that API entity specified by identifier is associated with the Gateway 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 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - gateway_id=gateway_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 - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - parameters: Optional[_models.AssociationContract] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiContract: - """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: Default value is None. - :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract - :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 create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiContract: - """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: 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: ApiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - parameters: Optional[Union[_models.AssociationContract, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.ApiContract: - """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: Is either a AssociationContract type or a IO[bytes] type. Default value is - None. - :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract 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 = { - 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: - if parameters is not None: - _json = self._serialize.body(parameters, "AssociationContract") - else: - _json = None - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_id, - api_id=api_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("ApiContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, resource_group_name: str, service_name: str, gateway_id: str, api_id: str, **kwargs: Any - ) -> None: - """Deletes the specified API from the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - gateway_id=gateway_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, 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/_gateway_certificate_authority_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py deleted file mode 100644 index 9def3c98c543..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_certificate_authority_operations.py +++ /dev/null @@ -1,552 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._gateway_certificate_authority_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GatewayCertificateAuthorityOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`gateway_certificate_authority` 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, - gateway_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayCertificateAuthorityContract"]: - """Lists the collection of Certificate Authorities for the specified Gateway 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 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - 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 - :return: An iterator like instance of either GatewayCertificateAuthorityContract or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract] - :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.GatewayCertificateAuthorityCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - gateway_id=gateway_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("GatewayCertificateAuthorityCollection", 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, gateway_id: str, certificate_id: str, **kwargs: Any - ) -> bool: - """Checks if Certificate entity is assigned to Gateway entity as Certificate Authority. - - :param resource_group_name: The name of the resource group. The name is 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 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 = { - 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, - gateway_id=gateway_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, gateway_id: str, certificate_id: str, **kwargs: Any - ) -> _models.GatewayCertificateAuthorityContract: - """Get assigned Gateway Certificate Authority 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 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API - Management service instance. Required. - :type certificate_id: str - :return: GatewayCertificateAuthorityContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayCertificateAuthorityContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_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("GatewayCertificateAuthorityContract", 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, - gateway_id: str, - certificate_id: str, - parameters: _models.GatewayCertificateAuthorityContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayCertificateAuthorityContract: - """Assign Certificate entity to Gateway entity as Certificate Authority. - - :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API - Management service instance. Required. - :type certificate_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :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: GatewayCertificateAuthorityContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - certificate_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayCertificateAuthorityContract: - """Assign Certificate entity to Gateway entity as Certificate Authority. - - :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API - Management service instance. Required. - :type certificate_id: str - :param 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: GatewayCertificateAuthorityContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - certificate_id: str, - parameters: Union[_models.GatewayCertificateAuthorityContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.GatewayCertificateAuthorityContract: - """Assign Certificate entity to Gateway entity as Certificate Authority. - - :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API - Management service instance. Required. - :type certificate_id: str - :param parameters: Is either a GatewayCertificateAuthorityContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract 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: GatewayCertificateAuthorityContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayCertificateAuthorityContract] = 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, "GatewayCertificateAuthorityContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_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("GatewayCertificateAuthorityContract", 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( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - certificate_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Remove relationship between Certificate Authority and Gateway 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 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 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 = { - 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, - gateway_id=gateway_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 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 deleted file mode 100644 index e5fdde2121e2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py +++ /dev/null @@ -1,549 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._gateway_hostname_configuration_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GatewayHostnameConfigurationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`gateway_hostname_configuration` 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, - gateway_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.GatewayHostnameConfigurationContract"]: - """Lists the collection of hostname configurations for the specified 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| hostname - | 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 GatewayHostnameConfigurationContract or the result - of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] - :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.GatewayHostnameConfigurationCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - gateway_id=gateway_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("GatewayHostnameConfigurationCollection", 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, gateway_id: str, hc_id: str, **kwargs: Any - ) -> bool: - """Checks that hostname configuration entity specified by identifier exists for specified Gateway - 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 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - gateway_id=gateway_id, - hc_id=hc_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, gateway_id: str, hc_id: str, **kwargs: Any - ) -> _models.GatewayHostnameConfigurationContract: - """Get details of a hostname configuration. - - :param resource_group_name: The name of the resource group. The name is 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :return: GatewayHostnameConfigurationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayHostnameConfigurationContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_id, - hc_id=hc_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("GatewayHostnameConfigurationContract", 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, - gateway_id: str, - hc_id: str, - parameters: _models.GatewayHostnameConfigurationContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayHostnameConfigurationContract: - """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :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: GatewayHostnameConfigurationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - hc_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayHostnameConfigurationContract: - """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :param 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: GatewayHostnameConfigurationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - hc_id: str, - parameters: Union[_models.GatewayHostnameConfigurationContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.GatewayHostnameConfigurationContract: - """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :param parameters: Is either a GatewayHostnameConfigurationContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract 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: GatewayHostnameConfigurationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayHostnameConfigurationContract] = 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, "GatewayHostnameConfigurationContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_id, - hc_id=hc_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("GatewayHostnameConfigurationContract", 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( - self, resource_group_name: str, service_name: str, gateway_id: str, hc_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified hostname configuration from the specified 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_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 = { - 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, - gateway_id=gateway_id, - hc_id=hc_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/_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py deleted file mode 100644 index 0fa13aef7d80..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py +++ /dev/null @@ -1,1377 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GatewayOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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") - - @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.GatewayContract"]: - """Lists a collection of gateways registered with 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| region | - 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 GatewayContract or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayContract] - :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.GatewayCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("GatewayCollection", 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, gateway_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the Gateway 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 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: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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 [200]: - map_error(status_code=response.status_code, 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, gateway_id: str, **kwargs: Any - ) -> _models.GatewayContract: - """Gets the details of the Gateway 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 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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayContract] = kwargs.pop("cls", None) - - _request = build_get_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 [200]: - map_error(status_code=response.status_code, 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("GatewayContract", 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, - gateway_id: str, - parameters: _models.GatewayContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayContract: - """Creates or updates a Gateway to be used in Api Management 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 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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract - :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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayContract: - """Creates or updates a Gateway to be used in Api Management 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 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: 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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: Union[_models.GatewayContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.GatewayContract: - """Creates or updates a Gateway to be used in Api Management 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 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: Is either a GatewayContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract 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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayContract] = 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, "GatewayContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_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("GatewayContract", 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, - gateway_id: str, - if_match: str, - parameters: _models.GatewayContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayContract: - """Updates the details of the gateway 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 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 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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayContract: - """Updates the details of the gateway 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 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 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: 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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - if_match: str, - parameters: Union[_models.GatewayContract, IO[bytes]], - **kwargs: Any - ) -> _models.GatewayContract: - """Updates the details of the gateway 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 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 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: Is either a GatewayContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or IO[bytes] - :return: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayContract] = 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, "GatewayContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_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("GatewayContract", 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( - self, resource_group_name: str, service_name: str, gateway_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific 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 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 = { - 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, - gateway_id=gateway_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_keys( - self, resource_group_name: str, service_name: str, gateway_id: str, **kwargs: Any - ) -> _models.GatewayKeysContract: - """Retrieves gateway 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 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: GatewayKeysContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayKeysContract] = kwargs.pop("cls", None) - - _request = build_list_keys_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 [200]: - map_error(status_code=response.status_code, 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("GatewayKeysContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def regenerate_key( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: _models.GatewayKeyRegenerationRequestContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Regenerates specified gateway key invalidating any tokens created with it. - - :param resource_group_name: The name of the resource group. The name is 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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def regenerate_key( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Regenerates specified gateway key invalidating any tokens created with it. - - :param resource_group_name: The name of the resource group. The name is 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: 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def regenerate_key( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: Union[_models.GatewayKeyRegenerationRequestContract, IO[bytes]], - **kwargs: Any - ) -> None: - """Regenerates specified gateway key invalidating any tokens created with it. - - :param resource_group_name: The name of the resource group. The name is 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: Is either a GatewayKeyRegenerationRequestContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract or - IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "GatewayKeyRegenerationRequestContract") - - _request = build_regenerate_key_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 [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 generate_token( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: _models.GatewayTokenRequestContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayTokenContract: - """Gets the Shared Access Authorization Token for the 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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GatewayTokenContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def generate_token( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayTokenContract: - """Gets the Shared Access Authorization Token for the 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: 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: GatewayTokenContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def generate_token( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: Union[_models.GatewayTokenRequestContract, IO[bytes]], - **kwargs: Any - ) -> _models.GatewayTokenContract: - """Gets the Shared Access Authorization Token for the 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: Is either a GatewayTokenRequestContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract or IO[bytes] - :return: GatewayTokenContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayTokenContract] = 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, "GatewayTokenRequestContract") - - _request = build_generate_token_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("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( - 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 = { - 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 = { - 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 = { - 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 - - return 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 deleted file mode 100644 index f6850773d42e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_global_schema_operations.py +++ /dev/null @@ -1,601 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GlobalSchemaOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.GlobalSchemaContract"]: - """Lists a collection of schemas registered with 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - schema_id: str, - parameters: Union[_models.GlobalSchemaContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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 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, - 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 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 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, - 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 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 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, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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/_graph_ql_api_resolver_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_operations.py deleted file mode 100644 index 6ac7ef1673df..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_operations.py +++ /dev/null @@ -1,722 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._graph_ql_api_resolver_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GraphQLApiResolverOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`graph_ql_api_resolver` 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, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ResolverContract"]: - """Lists a collection of the resolvers for the specified GraphQL 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 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 - |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| path | 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 ResolverContract or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ResolverContract] - :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.ResolverCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("ResolverCollection", 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, api_id: str, resolver_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the GraphQL API resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - resolver_id=resolver_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, api_id: str, resolver_id: str, **kwargs: Any - ) -> _models.ResolverContract: - """Gets the details of the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_id: str - :return: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ResolverContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - resolver_id=resolver_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("ResolverContract", 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, - api_id: str, - resolver_id: str, - parameters: _models.ResolverContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResolverContract: - """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ResolverContract - :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: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - resolver_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResolverContract: - """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - resolver_id: str, - parameters: Union[_models.ResolverContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.ResolverContract: - """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_id: str - :param parameters: Create parameters. Is either a ResolverContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.ResolverContract 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: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ResolverContract] = 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, "ResolverContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - resolver_id=resolver_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("ResolverContract", 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, - api_id: str, - resolver_id: str, - if_match: str, - parameters: _models.ResolverUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResolverContract: - """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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: GraphQL API Resolver Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ResolverUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - resolver_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResolverContract: - """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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: GraphQL API Resolver 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: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - resolver_id: str, - if_match: str, - parameters: Union[_models.ResolverUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.ResolverContract: - """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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: GraphQL API Resolver Update parameters. Is either a ResolverUpdateContract - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ResolverUpdateContract or IO[bytes] - :return: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ResolverContract] = 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, "ResolverUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - resolver_id=resolver_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("ResolverContract", 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( - self, resource_group_name: str, service_name: str, api_id: str, resolver_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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/_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 deleted file mode 100644 index 53d6283a5d7e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_graph_ql_api_resolver_policy_operations.py +++ /dev/null @@ -1,574 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._graph_ql_api_resolver_policy_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_entity_tag_request, - build_get_request, - build_list_by_resolver_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GraphQLApiResolverPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`graph_ql_api_resolver_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_resolver( - self, resource_group_name: str, service_name: str, api_id: str, resolver_id: str, **kwargs: Any - ) -> AsyncIterable["_models.PolicyContract"]: - """Get the list of policy configuration at the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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_resolver_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - resolver_id=resolver_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, - api_id: str, - resolver_id: str, - policy_id: Union[str, _models.PolicyIdName], - **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the GraphQL API resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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, - api_id: str, - resolver_id: str, - policy_id: Union[str, _models.PolicyIdName], - format: Union[str, _models.PolicyExportFormat] = "xml", - **kwargs: Any - ) -> _models.PolicyContract: - """Get the policy configuration at the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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, - api_id: str, - resolver_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 GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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, - api_id: str, - resolver_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 GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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, - api_id: str, - resolver_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 GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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( - self, - resource_group_name: str, - service_name: str, - api_id: str, - resolver_id: str, - policy_id: Union[str, _models.PolicyIdName], - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the policy configuration at the GraphQL Api Resolver. - - :param resource_group_name: The name of the resource group. The name is 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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/_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py deleted file mode 100644 index bf25f250c280..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py +++ /dev/null @@ -1,678 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GroupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: str, group_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific group 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 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 = { - 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, - 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/_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py deleted file mode 100644 index d8c2c475d220..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py +++ /dev/null @@ -1,363 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class GroupUserOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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/_identity_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py deleted file mode 100644 index 1cdbc3a5f1f2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py +++ /dev/null @@ -1,748 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._identity_provider_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_secrets_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class IdentityProviderOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`identity_provider` 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.IdentityProviderContract"]: - """Lists a collection of Identity Provider configured in the specified service instance. - - .. seealso:: - - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-aad#how-to-authorize-developer-accounts-using-azure-active-directory - - :param resource_group_name: The name of the resource group. The name 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 IdentityProviderContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderContract] - :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.IdentityProviderList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("IdentityProviderList", 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the identityProvider 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 identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - identity_provider_name=identity_provider_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) - - 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Gets the configuration details of the identity Provider configured in specified 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 identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :return: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IdentityProviderContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - identity_provider_name=identity_provider_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IdentityProviderContract", 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - parameters: _models.IdentityProviderCreateContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Creates or Updates the IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract - :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: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Creates or Updates the IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - parameters: Union[_models.IdentityProviderCreateContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Creates or Updates the IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param parameters: Create parameters. Is either a IdentityProviderCreateContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract 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: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IdentityProviderContract] = 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, "IdentityProviderCreateContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - identity_provider_name=identity_provider_name, - 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("IdentityProviderContract", 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - if_match: str, - parameters: _models.IdentityProviderUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Updates an existing IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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.IdentityProviderUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Updates an existing IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - if_match: str, - parameters: Union[_models.IdentityProviderUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Updates an existing IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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 IdentityProviderUpdateParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters or - IO[bytes] - :return: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IdentityProviderContract] = 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, "IdentityProviderUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - identity_provider_name=identity_provider_name, - 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("IdentityProviderContract", 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( - self, - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the specified identity provider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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 = { - 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, - identity_provider_name=identity_provider_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, 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - **kwargs: Any - ) -> _models.ClientSecretContract: - """Gets the client secret details of the Identity Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :return: ClientSecretContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ClientSecretContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_request( - resource_group_name=resource_group_name, - service_name=service_name, - identity_provider_name=identity_provider_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ClientSecretContract", 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/_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py deleted file mode 100644 index 6961970de772..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py +++ /dev/null @@ -1,227 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._issue_operations import 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class IssueOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`issue` 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.IssueContract"]: - """Lists a collection of issues in the specified 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| apiId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| - description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| state | 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 IssueContract or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueContract] - :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.IssueCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("IssueCollection", 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, issue_id: str, **kwargs: Any - ) -> _models.IssueContract: - """Gets API Management issue 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 issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :return: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - issue_id=issue_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("IssueContract", 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/_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py deleted file mode 100644 index 0f117def0225..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py +++ /dev/null @@ -1,679 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._logger_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class LoggerOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_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.LoggerContract"]: - """Lists a collection of loggers in the specified service instance. - - .. 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 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: 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 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 = { - 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, - 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/_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py deleted file mode 100644 index f754b36972ab..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py +++ /dev/null @@ -1,1037 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class NamedValueOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - is_key_vault_refresh_failed: Optional[bool] = None, - **kwargs: Any - ) -> AsyncIterable["_models.NamedValueContract"]: - """Lists a collection of named values defined within 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 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: When set to true, the response contains only named value - entities which failed refresh. Default value is None. - :type is_key_vault_refresh_failed: bool - :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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - named_value_id: str, - parameters: Union[_models.NamedValueCreateContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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, - 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 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, - 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 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, - 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, - named_value_id: str, - if_match: str, - parameters: Union[_models.NamedValueUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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, - 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 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, - 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 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, - 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( - self, resource_group_name: str, service_name: str, named_value_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific named value from 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, named_value_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - 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, 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 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, - 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/_network_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py deleted file mode 100644 index 0e986b6138a1..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py +++ /dev/null @@ -1,177 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, List, Optional, 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._network_status_operations import build_list_by_location_request, build_list_by_service_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class NetworkStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`network_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 list_by_service( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> List[_models.NetworkStatusContractByLocation]: - """Gets the Connectivity Status to the external resources on which the Api Management service - depends from inside the Cloud Service. This also returns the DNS Servers as visible to the - CloudService. - - :param resource_group_name: The name of the resource group. The name 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: list of NetworkStatusContractByLocation or the result of cls(response) - :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[List[_models.NetworkStatusContractByLocation]] = 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.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("[NetworkStatusContractByLocation]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def list_by_location( - self, resource_group_name: str, service_name: str, location_name: str, **kwargs: Any - ) -> _models.NetworkStatusContract: - """Gets the Connectivity Status to the external resources on which the Api Management service - depends from inside the Cloud Service. This also returns the DNS Servers as visible to the - CloudService. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param location_name: Location in which the API Management service is deployed. This is one of - the Azure Regions like West US, East US, South Central US. Required. - :type location_name: str - :return: NetworkStatusContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.NetworkStatusContract] = kwargs.pop("cls", None) - - _request = build_list_by_location_request( - resource_group_name=resource_group_name, - service_name=service_name, - location_name=location_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("NetworkStatusContract", 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/_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py deleted file mode 100644 index 336c03e534a3..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py +++ /dev/null @@ -1,298 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class NotificationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - notification_name: Union[str, _models.NotificationName], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.NotificationContract: - """Create or Update API Management publisher 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 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 = { - 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, - 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/_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py deleted file mode 100644 index 61a2a1698409..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py +++ /dev/null @@ -1,335 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class NotificationRecipientEmailOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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( - self, - resource_group_name: str, - service_name: 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 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 = { - 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, - 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/_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py deleted file mode 100644 index a2e4abdcb19a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py +++ /dev/null @@ -1,338 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class NotificationRecipientUserOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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( - self, - resource_group_name: str, - service_name: 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 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 = { - 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, - 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/_open_id_connect_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py deleted file mode 100644 index 9cde741be2f7..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py +++ /dev/null @@ -1,733 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._open_id_connect_provider_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_secrets_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class OpenIdConnectProviderOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`open_id_connect_provider` 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.OpenidConnectProviderContract"]: - """Lists of all the OpenId Connect Providers. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| 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 - :return: An iterator like instance of either OpenidConnectProviderContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] - :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.OpenIdConnectProviderCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("OpenIdConnectProviderCollection", 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, opid: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the openIdConnectProvider 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 opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - opid=opid, - 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, opid: str, **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Gets specific OpenID Connect Provider without secrets. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :return: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.OpenidConnectProviderContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - opid=opid, - 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("OpenidConnectProviderContract", 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, - opid: str, - parameters: _models.OpenidConnectProviderContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Creates or updates the OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :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: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - opid: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Creates or updates the OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - opid: str, - parameters: Union[_models.OpenidConnectProviderContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Creates or updates the OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :param parameters: Create parameters. Is either a OpenidConnectProviderContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract 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: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.OpenidConnectProviderContract] = 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, "OpenidConnectProviderContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - opid=opid, - 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("OpenidConnectProviderContract", 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, - opid: str, - if_match: str, - parameters: _models.OpenidConnectProviderUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Updates the specific OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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.OpenidConnectProviderUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - opid: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Updates the specific OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - opid: str, - if_match: str, - parameters: Union[_models.OpenidConnectProviderUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Updates the specific OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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 OpenidConnectProviderUpdateContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract or - IO[bytes] - :return: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.OpenidConnectProviderContract] = 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, "OpenidConnectProviderUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - opid=opid, - 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("OpenidConnectProviderContract", 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( - self, resource_group_name: str, service_name: str, opid: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific OpenID Connect Provider 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 opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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 = { - 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, - opid=opid, - 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_secrets( - self, resource_group_name: str, service_name: str, opid: str, **kwargs: Any - ) -> _models.ClientSecretContract: - """Gets the client secret details of the OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :return: ClientSecretContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ClientSecretContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_request( - resource_group_name=resource_group_name, - service_name=service_name, - opid=opid, - 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("ClientSecretContract", 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/_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py deleted file mode 100644 index 3b731658e591..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py +++ /dev/null @@ -1,172 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._operation_operations import build_list_by_tags_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class OperationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_tags( - self, - resource_group_name: str, - service_name: str, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - include_not_tagged_operations: Optional[bool] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TagResourceContract"]: - """Lists a collection of operations associated with tags. - - :param resource_group_name: The name of the resource group. The name is 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 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 - |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| method | 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 include_not_tagged_operations: Include not tagged Operations. Default value is None. - :type include_not_tagged_operations: bool - :return: An iterator like instance of either TagResourceContract or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :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.TagResourceCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_tags_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - include_not_tagged_operations=include_not_tagged_operations, - 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("TagResourceCollection", 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/_operation_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_status_operations.py deleted file mode 100644 index 4edfc523857d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_status_operations.py +++ /dev/null @@ -1,108 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operations.py new file mode 100644 index 000000000000..7dd4f6a1c060 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operations.py @@ -0,0 +1,85220 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +import datetime +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core import AsyncPipelineClient, MatchConditions +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceModifiedError, + 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 ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from ..._utils.serialization import Deserializer, Serializer +from ..._utils.utils import ClientMixinABC +from ...operations._operations import ( + build_all_policies_list_by_service_request, + build_api_create_or_update_request, + build_api_delete_request, + build_api_diagnostic_create_or_update_request, + build_api_diagnostic_delete_request, + build_api_diagnostic_get_entity_tag_request, + build_api_diagnostic_get_request, + build_api_diagnostic_list_by_service_request, + build_api_diagnostic_update_request, + build_api_export_get_request, + build_api_gateway_config_connection_create_or_update_request, + build_api_gateway_config_connection_delete_request, + build_api_gateway_config_connection_get_request, + build_api_gateway_config_connection_list_by_gateway_request, + build_api_gateway_create_or_update_request, + build_api_gateway_delete_request, + build_api_gateway_get_request, + build_api_gateway_hostname_binding_create_or_update_request, + build_api_gateway_hostname_binding_delete_request, + build_api_gateway_hostname_binding_get_request, + build_api_gateway_hostname_binding_list_by_gateway_request, + build_api_gateway_hostname_binding_refresh_secret_request, + build_api_gateway_list_by_resource_group_request, + build_api_gateway_list_request, + build_api_gateway_update_request, + build_api_get_entity_tag_request, + build_api_get_request, + build_api_issue_attachment_create_or_update_request, + build_api_issue_attachment_delete_request, + build_api_issue_attachment_get_entity_tag_request, + build_api_issue_attachment_get_request, + build_api_issue_attachment_list_by_service_request, + build_api_issue_comment_create_or_update_request, + build_api_issue_comment_delete_request, + build_api_issue_comment_get_entity_tag_request, + build_api_issue_comment_get_request, + build_api_issue_comment_list_by_service_request, + build_api_issue_create_or_update_request, + build_api_issue_delete_request, + build_api_issue_get_entity_tag_request, + build_api_issue_get_request, + build_api_issue_list_by_service_request, + build_api_issue_update_request, + build_api_list_by_service_request, + build_api_list_by_tags_request, + build_api_management_gateway_skus_list_available_skus_request, + build_api_management_operations_list_request, + build_api_management_perform_connectivity_check_async_request, + build_api_management_service_apply_network_configuration_updates_request, + build_api_management_service_backup_request, + build_api_management_service_check_name_availability_request, + build_api_management_service_create_or_update_request, + build_api_management_service_delete_request, + build_api_management_service_get_domain_ownership_identifier_request, + build_api_management_service_get_request, + build_api_management_service_get_sso_token_request, + build_api_management_service_list_by_resource_group_request, + build_api_management_service_list_request, + build_api_management_service_migrate_to_stv2_request, + build_api_management_service_refresh_hostnames_request, + build_api_management_service_restore_request, + build_api_management_service_skus_list_available_service_skus_request, + build_api_management_service_update_request, + build_api_management_skus_list_request, + build_api_management_workspace_link_get_request, + build_api_management_workspace_links_list_by_service_request, + build_api_operation_create_or_update_request, + build_api_operation_delete_request, + build_api_operation_get_entity_tag_request, + build_api_operation_get_request, + build_api_operation_list_by_api_request, + build_api_operation_policy_create_or_update_request, + build_api_operation_policy_delete_request, + build_api_operation_policy_get_entity_tag_request, + build_api_operation_policy_get_request, + build_api_operation_policy_list_by_operation_request, + build_api_operation_update_request, + build_api_policy_create_or_update_request, + build_api_policy_delete_request, + build_api_policy_get_entity_tag_request, + build_api_policy_get_request, + build_api_policy_list_by_api_request, + build_api_product_list_by_apis_request, + build_api_release_create_or_update_request, + build_api_release_delete_request, + build_api_release_get_entity_tag_request, + build_api_release_get_request, + build_api_release_list_by_service_request, + build_api_release_update_request, + build_api_revision_list_by_service_request, + build_api_schema_create_or_update_request, + build_api_schema_delete_request, + build_api_schema_get_entity_tag_request, + build_api_schema_get_request, + build_api_schema_list_by_api_request, + build_api_tag_description_create_or_update_request, + build_api_tag_description_delete_request, + build_api_tag_description_get_entity_tag_request, + build_api_tag_description_get_request, + build_api_tag_description_list_by_service_request, + build_api_tool_create_or_update_request, + build_api_tool_delete_request, + build_api_tool_get_entity_tag_request, + build_api_tool_get_request, + build_api_tool_list_by_api_request, + build_api_tool_update_request, + build_api_update_request, + build_api_version_set_create_or_update_request, + build_api_version_set_delete_request, + build_api_version_set_get_entity_tag_request, + build_api_version_set_get_request, + build_api_version_set_list_by_service_request, + build_api_version_set_update_request, + build_api_wiki_create_or_update_request, + build_api_wiki_delete_request, + build_api_wiki_get_entity_tag_request, + build_api_wiki_get_request, + build_api_wiki_update_request, + build_api_wikis_list_request, + build_authorization_access_policy_create_or_update_request, + build_authorization_access_policy_delete_request, + build_authorization_access_policy_get_request, + build_authorization_access_policy_list_by_authorization_request, + build_authorization_confirm_consent_code_request, + build_authorization_create_or_update_request, + build_authorization_delete_request, + build_authorization_get_request, + build_authorization_list_by_authorization_provider_request, + build_authorization_login_links_post_request, + build_authorization_provider_create_or_update_request, + build_authorization_provider_delete_request, + build_authorization_provider_get_request, + build_authorization_provider_list_by_service_request, + build_authorization_provider_refresh_secret_request, + build_authorization_server_create_or_update_request, + build_authorization_server_delete_request, + build_authorization_server_get_entity_tag_request, + build_authorization_server_get_request, + build_authorization_server_list_by_service_request, + build_authorization_server_list_secrets_request, + build_authorization_server_update_request, + build_backend_create_or_update_request, + build_backend_delete_request, + build_backend_get_entity_tag_request, + build_backend_get_request, + build_backend_list_by_service_request, + build_backend_reconnect_request, + build_backend_update_request, + build_cache_create_or_update_request, + build_cache_delete_request, + build_cache_get_entity_tag_request, + build_cache_get_request, + build_cache_list_by_service_request, + build_cache_update_request, + build_certificate_create_or_update_request, + build_certificate_delete_request, + build_certificate_get_entity_tag_request, + build_certificate_get_request, + build_certificate_list_by_service_request, + build_certificate_refresh_secret_request, + build_client_application_create_or_update_request, + build_client_application_delete_request, + build_client_application_get_entity_tag_request, + build_client_application_get_request, + build_client_application_list_by_service_request, + build_client_application_list_secrets_request, + build_client_application_product_link_create_request, + build_client_application_product_link_delete_request, + build_client_application_product_link_get_request, + build_client_application_product_link_list_by_client_applications_request, + build_content_item_create_or_update_request, + build_content_item_delete_request, + build_content_item_get_entity_tag_request, + build_content_item_get_request, + build_content_item_list_by_service_request, + build_content_type_create_or_update_request, + build_content_type_delete_request, + build_content_type_get_request, + build_content_type_list_by_service_request, + build_delegation_settings_create_or_update_request, + build_delegation_settings_get_entity_tag_request, + build_delegation_settings_get_request, + build_delegation_settings_list_secrets_request, + build_delegation_settings_update_request, + build_deleted_services_get_by_name_request, + build_deleted_services_list_by_subscription_request, + build_deleted_services_purge_request, + build_diagnostic_create_or_update_request, + build_diagnostic_delete_request, + build_diagnostic_get_entity_tag_request, + build_diagnostic_get_request, + build_diagnostic_list_by_service_request, + build_diagnostic_update_request, + build_documentation_create_or_update_request, + build_documentation_delete_request, + build_documentation_get_entity_tag_request, + build_documentation_get_request, + build_documentation_list_by_service_request, + build_documentation_update_request, + build_email_template_create_or_update_request, + build_email_template_delete_request, + build_email_template_get_entity_tag_request, + build_email_template_get_request, + build_email_template_list_by_service_request, + build_email_template_update_request, + build_gateway_api_create_or_update_request, + build_gateway_api_delete_request, + build_gateway_api_get_entity_tag_request, + build_gateway_api_list_by_service_request, + build_gateway_certificate_authority_create_or_update_request, + build_gateway_certificate_authority_delete_request, + build_gateway_certificate_authority_get_entity_tag_request, + build_gateway_certificate_authority_get_request, + build_gateway_certificate_authority_list_by_service_request, + build_gateway_create_or_update_request, + build_gateway_delete_request, + build_gateway_generate_token_request, + build_gateway_get_entity_tag_request, + build_gateway_get_request, + build_gateway_hostname_configuration_create_or_update_request, + build_gateway_hostname_configuration_delete_request, + build_gateway_hostname_configuration_get_entity_tag_request, + build_gateway_hostname_configuration_get_request, + build_gateway_hostname_configuration_list_by_service_request, + build_gateway_invalidate_debug_credentials_request, + build_gateway_list_by_service_request, + build_gateway_list_debug_credentials_request, + build_gateway_list_keys_request, + build_gateway_list_trace_request, + build_gateway_regenerate_key_request, + build_gateway_update_request, + build_global_schema_create_or_update_request, + build_global_schema_delete_request, + build_global_schema_get_entity_tag_request, + build_global_schema_get_request, + build_global_schema_list_by_service_request, + build_graph_ql_api_resolver_create_or_update_request, + build_graph_ql_api_resolver_delete_request, + build_graph_ql_api_resolver_get_entity_tag_request, + build_graph_ql_api_resolver_get_request, + build_graph_ql_api_resolver_list_by_api_request, + build_graph_ql_api_resolver_policy_create_or_update_request, + build_graph_ql_api_resolver_policy_delete_request, + build_graph_ql_api_resolver_policy_get_entity_tag_request, + build_graph_ql_api_resolver_policy_get_request, + build_graph_ql_api_resolver_policy_list_by_resolver_request, + build_graph_ql_api_resolver_update_request, + build_group_create_or_update_request, + build_group_delete_request, + build_group_get_entity_tag_request, + build_group_get_request, + build_group_list_by_service_request, + build_group_update_request, + build_group_user_check_entity_exists_request, + build_group_user_create_request, + build_group_user_delete_request, + build_group_user_list_request, + build_identity_provider_create_or_update_request, + build_identity_provider_delete_request, + build_identity_provider_get_entity_tag_request, + build_identity_provider_get_request, + build_identity_provider_list_by_service_request, + build_identity_provider_list_secrets_request, + build_identity_provider_update_request, + build_issue_get_request, + build_issue_list_by_service_request, + build_logger_create_or_update_request, + build_logger_delete_request, + build_logger_get_entity_tag_request, + build_logger_get_request, + build_logger_list_by_service_request, + build_logger_update_request, + build_named_value_create_or_update_request, + build_named_value_delete_request, + build_named_value_get_entity_tag_request, + build_named_value_get_request, + build_named_value_list_by_service_request, + build_named_value_list_value_request, + build_named_value_refresh_secret_request, + build_named_value_update_request, + build_network_status_list_by_location_request, + build_network_status_list_by_service_request, + build_notification_create_or_update_request, + build_notification_get_request, + build_notification_list_by_service_request, + build_notification_recipient_email_check_entity_exists_request, + build_notification_recipient_email_create_or_update_request, + build_notification_recipient_email_delete_request, + build_notification_recipient_email_list_by_notification_request, + build_notification_recipient_user_check_entity_exists_request, + build_notification_recipient_user_create_or_update_request, + build_notification_recipient_user_delete_request, + build_notification_recipient_user_list_by_notification_request, + build_open_id_connect_provider_create_or_update_request, + build_open_id_connect_provider_delete_request, + build_open_id_connect_provider_get_entity_tag_request, + build_open_id_connect_provider_get_request, + build_open_id_connect_provider_list_by_service_request, + build_open_id_connect_provider_list_secrets_request, + build_open_id_connect_provider_update_request, + build_operation_list_by_tags_request, + build_operation_status_get_request, + build_operations_results_get_request, + build_outbound_network_dependencies_endpoints_list_by_service_request, + build_policy_create_or_update_request, + build_policy_delete_request, + build_policy_description_list_by_service_request, + build_policy_fragment_create_or_update_request, + build_policy_fragment_delete_request, + build_policy_fragment_get_entity_tag_request, + build_policy_fragment_get_request, + build_policy_fragment_list_by_service_request, + build_policy_fragment_list_references_request, + build_policy_get_entity_tag_request, + build_policy_get_request, + build_policy_list_by_service_request, + build_policy_restriction_create_or_update_request, + build_policy_restriction_delete_request, + build_policy_restriction_get_entity_tag_request, + build_policy_restriction_get_request, + build_policy_restriction_list_by_service_request, + build_policy_restriction_update_request, + build_policy_restriction_validations_by_service_request, + build_portal_config_create_or_update_request, + build_portal_config_get_entity_tag_request, + build_portal_config_get_request, + build_portal_config_list_by_service_request, + build_portal_config_update_request, + build_portal_revision_create_or_update_request, + build_portal_revision_get_entity_tag_request, + build_portal_revision_get_request, + build_portal_revision_list_by_service_request, + build_portal_revision_update_request, + build_portal_settings_list_by_service_request, + build_private_endpoint_connection_create_or_update_request, + build_private_endpoint_connection_delete_request, + build_private_endpoint_connection_get_by_name_request, + build_private_endpoint_connection_get_private_link_resource_request, + build_private_endpoint_connection_list_by_service_request, + build_private_endpoint_connection_list_private_link_resources_request, + build_product_api_check_entity_exists_request, + build_product_api_create_or_update_request, + build_product_api_delete_request, + build_product_api_link_create_or_update_request, + build_product_api_link_delete_request, + build_product_api_link_get_request, + build_product_api_link_list_by_product_request, + build_product_api_list_by_product_request, + build_product_create_or_update_request, + build_product_delete_request, + build_product_get_entity_tag_request, + build_product_get_request, + build_product_group_check_entity_exists_request, + build_product_group_create_or_update_request, + build_product_group_delete_request, + build_product_group_link_create_or_update_request, + build_product_group_link_delete_request, + build_product_group_link_get_request, + build_product_group_link_list_by_product_request, + build_product_group_list_by_product_request, + build_product_list_by_service_request, + build_product_list_by_tags_request, + build_product_policy_create_or_update_request, + build_product_policy_delete_request, + build_product_policy_get_entity_tag_request, + build_product_policy_get_request, + build_product_policy_list_by_product_request, + build_product_subscriptions_list_request, + build_product_update_request, + build_product_wiki_create_or_update_request, + build_product_wiki_delete_request, + build_product_wiki_get_entity_tag_request, + build_product_wiki_get_request, + build_product_wiki_update_request, + build_product_wikis_list_request, + build_quota_by_counter_keys_list_by_service_request, + build_quota_by_counter_keys_update_request, + build_quota_by_period_keys_get_request, + build_quota_by_period_keys_update_request, + build_region_list_by_service_request, + build_reports_list_by_api_request, + build_reports_list_by_geo_request, + build_reports_list_by_operation_request, + build_reports_list_by_product_request, + build_reports_list_by_request_request, + build_reports_list_by_subscription_request, + build_reports_list_by_time_request, + build_reports_list_by_user_request, + build_sign_in_settings_create_or_update_request, + build_sign_in_settings_get_entity_tag_request, + build_sign_in_settings_get_request, + build_sign_in_settings_update_request, + build_sign_up_settings_create_or_update_request, + build_sign_up_settings_get_entity_tag_request, + build_sign_up_settings_get_request, + build_sign_up_settings_update_request, + build_subscription_create_or_update_request, + build_subscription_delete_request, + build_subscription_get_entity_tag_request, + build_subscription_get_request, + build_subscription_list_request, + build_subscription_list_secrets_request, + build_subscription_regenerate_primary_key_request, + build_subscription_regenerate_secondary_key_request, + build_subscription_update_request, + build_tag_api_link_create_or_update_request, + build_tag_api_link_delete_request, + build_tag_api_link_get_request, + build_tag_api_link_list_by_product_request, + build_tag_assign_to_api_request, + build_tag_assign_to_operation_request, + build_tag_assign_to_product_request, + build_tag_create_or_update_request, + build_tag_delete_request, + build_tag_detach_from_api_request, + build_tag_detach_from_operation_request, + build_tag_detach_from_product_request, + build_tag_get_by_api_request, + build_tag_get_by_operation_request, + build_tag_get_by_product_request, + build_tag_get_entity_state_by_api_request, + build_tag_get_entity_state_by_operation_request, + build_tag_get_entity_state_by_product_request, + build_tag_get_entity_state_request, + build_tag_get_request, + build_tag_list_by_api_request, + build_tag_list_by_operation_request, + build_tag_list_by_product_request, + build_tag_list_by_service_request, + build_tag_operation_link_create_or_update_request, + build_tag_operation_link_delete_request, + build_tag_operation_link_get_request, + build_tag_operation_link_list_by_product_request, + build_tag_product_link_create_or_update_request, + build_tag_product_link_delete_request, + build_tag_product_link_get_request, + build_tag_product_link_list_by_product_request, + build_tag_resource_list_by_service_request, + build_tag_update_request, + build_tenant_access_create_request, + build_tenant_access_get_entity_tag_request, + build_tenant_access_get_request, + build_tenant_access_git_regenerate_primary_key_request, + build_tenant_access_git_regenerate_secondary_key_request, + build_tenant_access_list_by_service_request, + build_tenant_access_list_secrets_request, + build_tenant_access_regenerate_primary_key_request, + build_tenant_access_regenerate_secondary_key_request, + build_tenant_access_update_request, + build_tenant_configuration_deploy_request, + build_tenant_configuration_get_sync_state_request, + build_tenant_configuration_save_request, + build_tenant_configuration_validate_request, + build_tenant_settings_get_request, + build_tenant_settings_list_by_service_request, + build_user_confirmation_password_send_request, + build_user_create_or_update_request, + build_user_delete_request, + build_user_generate_sso_url_request, + build_user_get_entity_tag_request, + build_user_get_request, + build_user_get_shared_access_token_request, + build_user_group_list_request, + build_user_identities_list_request, + build_user_list_by_service_request, + build_user_subscription_get_request, + build_user_subscription_list_request, + build_user_update_request, + build_workspace_api_create_or_update_request, + build_workspace_api_delete_request, + build_workspace_api_diagnostic_create_or_update_request, + build_workspace_api_diagnostic_delete_request, + build_workspace_api_diagnostic_get_entity_tag_request, + build_workspace_api_diagnostic_get_request, + build_workspace_api_diagnostic_list_by_workspace_request, + build_workspace_api_diagnostic_update_request, + build_workspace_api_export_get_request, + build_workspace_api_get_entity_tag_request, + build_workspace_api_get_request, + build_workspace_api_list_by_service_request, + build_workspace_api_operation_create_or_update_request, + build_workspace_api_operation_delete_request, + build_workspace_api_operation_get_entity_tag_request, + build_workspace_api_operation_get_request, + build_workspace_api_operation_list_by_api_request, + build_workspace_api_operation_policy_create_or_update_request, + build_workspace_api_operation_policy_delete_request, + build_workspace_api_operation_policy_get_entity_tag_request, + build_workspace_api_operation_policy_get_request, + build_workspace_api_operation_policy_list_by_operation_request, + build_workspace_api_operation_update_request, + build_workspace_api_policy_create_or_update_request, + build_workspace_api_policy_delete_request, + build_workspace_api_policy_get_entity_tag_request, + build_workspace_api_policy_get_request, + build_workspace_api_policy_list_by_api_request, + build_workspace_api_release_create_or_update_request, + build_workspace_api_release_delete_request, + build_workspace_api_release_get_entity_tag_request, + build_workspace_api_release_get_request, + build_workspace_api_release_list_by_service_request, + build_workspace_api_release_update_request, + build_workspace_api_revision_list_by_service_request, + build_workspace_api_schema_create_or_update_request, + build_workspace_api_schema_delete_request, + build_workspace_api_schema_get_entity_tag_request, + build_workspace_api_schema_get_request, + build_workspace_api_schema_list_by_api_request, + build_workspace_api_update_request, + build_workspace_api_version_set_create_or_update_request, + build_workspace_api_version_set_delete_request, + build_workspace_api_version_set_get_entity_tag_request, + build_workspace_api_version_set_get_request, + build_workspace_api_version_set_list_by_service_request, + build_workspace_api_version_set_update_request, + build_workspace_backend_create_or_update_request, + build_workspace_backend_delete_request, + build_workspace_backend_get_entity_tag_request, + build_workspace_backend_get_request, + build_workspace_backend_list_by_workspace_request, + build_workspace_backend_update_request, + build_workspace_certificate_create_or_update_request, + build_workspace_certificate_delete_request, + build_workspace_certificate_get_entity_tag_request, + build_workspace_certificate_get_request, + build_workspace_certificate_list_by_workspace_request, + build_workspace_certificate_refresh_secret_request, + build_workspace_create_or_update_request, + build_workspace_delete_request, + build_workspace_diagnostic_create_or_update_request, + build_workspace_diagnostic_delete_request, + build_workspace_diagnostic_get_entity_tag_request, + build_workspace_diagnostic_get_request, + build_workspace_diagnostic_list_by_workspace_request, + build_workspace_diagnostic_update_request, + build_workspace_get_entity_tag_request, + build_workspace_get_request, + build_workspace_global_schema_create_or_update_request, + build_workspace_global_schema_delete_request, + build_workspace_global_schema_get_entity_tag_request, + build_workspace_global_schema_get_request, + build_workspace_global_schema_list_by_service_request, + build_workspace_group_create_or_update_request, + build_workspace_group_delete_request, + build_workspace_group_get_entity_tag_request, + build_workspace_group_get_request, + build_workspace_group_list_by_service_request, + build_workspace_group_update_request, + build_workspace_group_user_check_entity_exists_request, + build_workspace_group_user_create_request, + build_workspace_group_user_delete_request, + build_workspace_group_user_list_request, + build_workspace_list_by_service_request, + build_workspace_logger_create_or_update_request, + build_workspace_logger_delete_request, + build_workspace_logger_get_entity_tag_request, + build_workspace_logger_get_request, + build_workspace_logger_list_by_workspace_request, + build_workspace_logger_update_request, + build_workspace_named_value_create_or_update_request, + build_workspace_named_value_delete_request, + build_workspace_named_value_get_entity_tag_request, + build_workspace_named_value_get_request, + build_workspace_named_value_list_by_service_request, + build_workspace_named_value_list_value_request, + build_workspace_named_value_refresh_secret_request, + build_workspace_named_value_update_request, + build_workspace_notification_create_or_update_request, + build_workspace_notification_get_request, + build_workspace_notification_list_by_service_request, + build_workspace_notification_recipient_email_check_entity_exists_request, + build_workspace_notification_recipient_email_create_or_update_request, + build_workspace_notification_recipient_email_delete_request, + build_workspace_notification_recipient_email_list_by_notification_request, + build_workspace_notification_recipient_user_check_entity_exists_request, + build_workspace_notification_recipient_user_create_or_update_request, + build_workspace_notification_recipient_user_delete_request, + build_workspace_notification_recipient_user_list_by_notification_request, + build_workspace_policy_create_or_update_request, + build_workspace_policy_delete_request, + build_workspace_policy_fragment_create_or_update_request, + build_workspace_policy_fragment_delete_request, + build_workspace_policy_fragment_get_entity_tag_request, + build_workspace_policy_fragment_get_request, + build_workspace_policy_fragment_list_by_service_request, + build_workspace_policy_fragment_list_references_request, + build_workspace_policy_get_entity_tag_request, + build_workspace_policy_get_request, + build_workspace_policy_list_by_api_request, + build_workspace_product_api_link_create_or_update_request, + build_workspace_product_api_link_delete_request, + build_workspace_product_api_link_get_request, + build_workspace_product_api_link_list_by_product_request, + build_workspace_product_create_or_update_request, + build_workspace_product_delete_request, + build_workspace_product_get_entity_tag_request, + build_workspace_product_get_request, + build_workspace_product_group_link_create_or_update_request, + build_workspace_product_group_link_delete_request, + build_workspace_product_group_link_get_request, + build_workspace_product_group_link_list_by_product_request, + build_workspace_product_list_by_service_request, + build_workspace_product_policy_create_or_update_request, + build_workspace_product_policy_delete_request, + build_workspace_product_policy_get_entity_tag_request, + build_workspace_product_policy_get_request, + build_workspace_product_policy_list_by_product_request, + build_workspace_product_update_request, + build_workspace_subscription_create_or_update_request, + build_workspace_subscription_delete_request, + build_workspace_subscription_get_entity_tag_request, + build_workspace_subscription_get_request, + build_workspace_subscription_list_request, + build_workspace_subscription_list_secrets_request, + build_workspace_subscription_regenerate_primary_key_request, + build_workspace_subscription_regenerate_secondary_key_request, + build_workspace_subscription_update_request, + build_workspace_tag_api_link_create_or_update_request, + build_workspace_tag_api_link_delete_request, + build_workspace_tag_api_link_get_request, + build_workspace_tag_api_link_list_by_product_request, + build_workspace_tag_create_or_update_request, + build_workspace_tag_delete_request, + build_workspace_tag_get_entity_state_request, + build_workspace_tag_get_request, + build_workspace_tag_list_by_service_request, + build_workspace_tag_operation_link_create_or_update_request, + build_workspace_tag_operation_link_delete_request, + build_workspace_tag_operation_link_get_request, + build_workspace_tag_operation_link_list_by_product_request, + build_workspace_tag_product_link_create_or_update_request, + build_workspace_tag_product_link_delete_request, + build_workspace_tag_product_link_get_request, + build_workspace_tag_product_link_list_by_product_request, + build_workspace_tag_update_request, + build_workspace_update_request, +) +from .._configuration import ApiManagementClientConfiguration + +JSON = MutableMapping[str, Any] +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +List = list + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **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. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns ApiContract. The ApiContract is compatible + with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns ApiContract. The ApiContract is compatible + with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns ApiContract. The ApiContract is compatible + with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + ApiCreateOrUpdateParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns ApiContract. The ApiContract is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.ApiContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + parameters: _models.ApiUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Update Contract parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Update Contract parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Update Contract parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :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, + parameters: Union[_models.ApiUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: API Update Contract parameters. Is one of the following types: + ApiUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_revisions: Delete all revisions of the Api. Default value is None. + :paramtype delete_revisions: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_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, + etag=etag, + match_condition=match_condition, + delete_revisions=delete_revisions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.ApiContract"]: + """Lists all APIs 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword tags: Include tags in the response. Default value is None. + :paramtype tags: str + :keyword expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. + :paramtype expand_api_version_set: bool + :return: An iterator like instance of ApiContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_release_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, + 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_release_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: ApiReleaseContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_release_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + 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, + parameters: _models.ApiReleaseContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Release Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Release Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Release Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + parameters: Union[_models.ApiReleaseContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: API Release Update parameters. Is one of the following types: + ApiReleaseContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_release_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_release_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| notes | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiReleaseContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiReleaseContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_release_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiReleaseContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, + 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: OperationContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_operation_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + 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, + parameters: _models.OperationUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Operation Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Operation Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Operation Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + parameters: Union[_models.OperationUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: API Operation Update parameters. Is one of the following types: + OperationUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_operation_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword tags: Include tags in the response. Default value is None. + :paramtype tags: str + :return: An iterator like instance of OperationContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OperationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_operation_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OperationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class GraphQLApiResolverPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`graph_ql_api_resolver_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the GraphQL API resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_graph_ql_api_resolver_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the GraphQL Api Resolver. + + :param resource_group_name: The name of the resource group. The name is 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resolver( + self, resource_group_name: str, service_name: str, api_id: str, resolver_id: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyContract"]: + """Get the list of policy configuration at the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :return: An iterator like instance of PolicyContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_graph_ql_api_resolver_policy_list_by_resolver_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_api_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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_by_api( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> _models.PolicyCollection: + """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 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: PolicyCollection. The PolicyCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + _request = build_api_policy_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Get the Global policy definition 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_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, policy_id: Union[str, _models.PolicyIdName], **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Global policy definition 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_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates the global policy 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_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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates the global policy 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_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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates the global policy 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_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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates the global policy 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_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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the global policy 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_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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. + 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 PolicyContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_policy_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ProductPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_product_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_product( + self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any + ) -> AsyncItemPaged["_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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: An iterator like instance of PolicyContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_workspace_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, + 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_policy_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_policy_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any + ) -> AsyncItemPaged["_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 PolicyContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, + 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_operation_policy_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_policy_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 PolicyContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_operation_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, + 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_policy_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_policy_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, **kwargs: Any + ) -> AsyncItemPaged["_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 PolicyContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_workspace_product_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_policy_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_policy_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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_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. The PolicyCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + _request = build_workspace_product_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class TagOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tag` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get_by_api( + self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Get tag associated with 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_get_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_state_by_api( + self, resource_group_name: str, service_name: str, api_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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_get_entity_state_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 assign_to_api( + self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Assign tag to 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_assign_to_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def detach_from_api( + self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any + ) -> None: + """Detach the tag from 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_detach_from_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.TagContract"]: + """Lists all Tags associated with 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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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_by_operation( + self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Get tag associated with the 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_get_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_state_by_operation( + self, resource_group_name: str, service_name: str, api_id: str, operation_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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_get_entity_state_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 assign_to_operation( + self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Assign tag to the 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_assign_to_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def detach_from_operation( + self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any + ) -> None: + """Detach the tag from the 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_detach_from_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_operation( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.TagContract"]: + """Lists all Tags associated with the 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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_list_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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_by_product( + self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Get tag associated with 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_get_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_state_by_product( + self, resource_group_name: str, service_name: str, product_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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_get_entity_state_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 assign_to_product( + self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Assign tag to 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_assign_to_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def detach_from_product( + self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any + ) -> None: + """Detach the tag from 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_detach_from_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.TagContract"]: + """Lists all Tags associated with 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, **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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_state(self, resource_group_name: str, service_name: 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_get_entity_state_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: _models.TagCreateUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + tag_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + tag_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + tag_id: str, + parameters: Union[_models.TagCreateUpdateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Create parameters. Is one of the following types: TagCreateUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + 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, + tag_id: str, + parameters: _models.TagCreateUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + tag_id: str, + parameters: Union[_models.TagCreateUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Update parameters. Is one of the following types: TagCreateUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific tag 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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, + scope: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.TagContract"]: + """Lists a collection of tags 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. + :paramtype scope: str + :return: An iterator like instance of TagContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_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, + scope=scope, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_workspace_tag_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + parameters: _models.TagCreateUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: TagCreateUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + 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, + parameters: _models.TagCreateUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + parameters: Union[_models.TagCreateUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: TagCreateUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. + :paramtype scope: str + :return: An iterator like instance of TagContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_tag_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The SchemaContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SchemaContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SchemaContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + 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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_schema_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns SchemaContract. The SchemaContract is + compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns SchemaContract. The SchemaContract is + compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns SchemaContract. The SchemaContract is + compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: SchemaContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns SchemaContract. The SchemaContract is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.SchemaContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword force: If true removes all references to the schema before deleting it. Default value + is None. + :paramtype force: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_schema_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, + etag=etag, + match_condition=match_condition, + force=force, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| contentType + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SchemaContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SchemaContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SchemaContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`diagnostic` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_diagnostic_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_diagnostic_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + diagnostic_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + diagnostic_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Is one of the following types: DiagnosticContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_diagnostic_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + etag: str, + match_condition: MatchConditions, + 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Diagnostic Update parameters. Is one of the following types: + DiagnosticContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_diagnostic_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_diagnostic_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.DiagnosticContract"]: + """Lists all diagnostics 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DiagnosticContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiagnosticContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DiagnosticContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_workspace_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: DiagnosticContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_diagnostic_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + parameters: _models.DiagnosticUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: Union[_models.DiagnosticUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Diagnostic Update parameters. Is one of the following types: + DiagnosticUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_diagnostic_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_diagnostic_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DiagnosticContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiagnosticContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DiagnosticContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, + 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: DiagnosticContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_diagnostic_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + parameters: _models.DiagnosticUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: Union[_models.DiagnosticUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Diagnostic Update parameters. Is one of the following types: + DiagnosticUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_diagnostic_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_diagnostic_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DiagnosticContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiagnosticContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DiagnosticContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class IssueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`issue` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, issue_id: str, **kwargs: Any + ) -> _models.IssueContract: + """Gets API Management issue 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IssueContract] = kwargs.pop("cls", None) + + _request = build_issue_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + ) -> AsyncItemPaged["_models.IssueContract"]: + """Lists a collection of issues in the specified 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| state | filter | eq | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of IssueContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IssueContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_issue_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IssueContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ProductWikiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_wiki` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, product_id: str, **kwargs: Any + ) -> _models.WikiContract: + """Gets the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + _request = build_product_wiki_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_wiki_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: _models.WikiContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: Union[_models.WikiContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create parameters. Is one of the following types: WikiContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_wiki_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + 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, + product_id: str, + parameters: _models.WikiUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: Union[_models.WikiUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Wiki Update parameters. Is one of the following types: WikiUpdateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_wiki_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + product_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified Wiki from 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_wiki_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_version_set_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_version_set_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + parameters: _models.ApiVersionSetContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + ApiVersionSetContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_version_set_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + 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, + parameters: _models.ApiVersionSetUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + parameters: Union[_models.ApiVersionSetUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: + ApiVersionSetUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_version_set_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_version_set_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiVersionSetContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiVersionSetContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_version_set_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiVersionSetContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + _request = build_workspace_backend_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_backend_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + parameters: _models.BackendContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: BackendContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_backend_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + 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, + parameters: _models.BackendUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + parameters: Union[_models.BackendUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: BackendUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_backend_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_backend_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of BackendContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.BackendContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.BackendContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_backend_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.BackendContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_workspace_certificate_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_certificate_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + parameters: _models.CertificateCreateOrUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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 one of the following types: + CertificateCreateOrUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_certificate_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_certificate_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword is_key_vault_refresh_failed: When set to true, the response contains only certificates + entities which failed refresh. Default value is None. + :paramtype is_key_vault_refresh_failed: bool + :return: An iterator like instance of CertificateContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CertificateContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CertificateContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_certificate_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CertificateContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type 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. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_workspace_certificate_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + _request = build_workspace_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + parameters: _models.GroupCreateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: GroupCreateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_group_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + 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, + parameters: _models.GroupUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + parameters: Union[_models.GroupUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: GroupUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_group_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_group_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.GroupContract"]: + """Lists a collection of groups 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GroupContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GroupContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GroupContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + _request = build_workspace_logger_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_logger_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + parameters: _models.LoggerContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: LoggerContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_logger_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + 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, + parameters: _models.LoggerUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + parameters: Union[_models.LoggerUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: LoggerUpdateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_logger_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_logger_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.LoggerContract"]: + """Lists a collection of loggers 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of LoggerContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.LoggerContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LoggerContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_logger_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LoggerContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The NamedValueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NamedValueContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + 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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_named_value_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: NamedValueCreateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + parameters: Union[_models.NamedValueUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_named_value_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + parameters: _models.NamedValueUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, + parameters: Union[_models.NamedValueUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: + NamedValueUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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 = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.NamedValueContract"]: + """Lists a collection of named values 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword 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. + :paramtype is_key_vault_refresh_failed: str or + ~azure.mgmt.apimanagement.models.KeyVaultRefreshState + :return: An iterator like instance of NamedValueContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NamedValueContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NamedValueContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @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. The NamedValueSecretContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamedValueSecretContract] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NamedValueSecretContract, response.json()) + + 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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 NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The NotificationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_workspace_notification_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NotificationContract, response.json()) + + 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], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: NotificationContract. The NotificationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_workspace_notification_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NotificationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of NotificationContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NotificationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NotificationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_notification_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NotificationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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 + :keyword format: Policy fragment content format. Known values are: "xml" and "rawxml". Default + value is None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :return: PolicyFragmentContract. The PolicyFragmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyFragmentContract] = kwargs.pop("cls", None) + + _request = build_workspace_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyFragmentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: Union[_models.PolicyFragmentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_policy_fragment_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + PolicyFragmentContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.PolicyFragmentContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_policy_fragment_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of PolicyFragmentContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyFragmentContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyFragmentContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @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 + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: ResourceCollection. The ResourceCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ResourceCollection] = kwargs.pop("cls", None) + + _request = build_workspace_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class SignInSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`sign_in_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any) -> _models.PortalSigninSettings: + """Get Sign In Settings for the Portal. + + :param resource_group_name: The name of the resource group. The name 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: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalSigninSettings] = kwargs.pop("cls", None) + + _request = build_sign_in_settings_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSigninSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the SignInSettings. + + :param resource_group_name: The name of the resource group. The name 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: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sign_in_settings_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalSigninSettings, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSigninSettings: + """Create or Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSigninSettings: + """Create or Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSigninSettings: + """Create or Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalSigninSettings, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSigninSettings: + """Create or Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is one of the following types: + PortalSigninSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalSigninSettings] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sign_in_settings_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSigninSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalSigninSettings, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-In settings. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-In settings. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-In settings. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalSigninSettings, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-In settings. Is one of the following types: + PortalSigninSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sign_in_settings_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class SignUpSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`sign_up_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any) -> _models.PortalSignupSettings: + """Get Sign Up Settings for the Portal. + + :param resource_group_name: The name of the resource group. The name 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: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalSignupSettings] = kwargs.pop("cls", None) + + _request = build_sign_up_settings_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSignupSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the SignUpSettings. + + :param resource_group_name: The name of the resource group. The name 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: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sign_up_settings_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalSignupSettings, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSignupSettings: + """Create or Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSignupSettings: + """Create or Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSignupSettings: + """Create or Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalSignupSettings, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSignupSettings: + """Create or Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is one of the following types: + PortalSignupSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalSignupSettings] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sign_up_settings_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSignupSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalSignupSettings, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-Up settings. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-Up settings. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-Up settings. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalSignupSettings, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-Up settings. Is one of the following types: + PortalSignupSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sign_up_settings_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DelegationSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`delegation_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any) -> _models.PortalDelegationSettings: + """Get Delegation Settings for the Portal. + + :param resource_group_name: The name of the resource group. The name 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: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalDelegationSettings] = kwargs.pop("cls", None) + + _request = build_delegation_settings_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalDelegationSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the DelegationSettings. + + :param resource_group_name: The name of the resource group. The name 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: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delegation_settings_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalDelegationSettings, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalDelegationSettings: + """Create or Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalDelegationSettings: + """Create or Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalDelegationSettings: + """Create or Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalDelegationSettings, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalDelegationSettings: + """Create or Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is one of the following types: + PortalDelegationSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalDelegationSettings] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_delegation_settings_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalDelegationSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalDelegationSettings, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Delegation settings. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Delegation settings. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Delegation settings. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalDelegationSettings, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Delegation settings. Is one of the following types: + PortalDelegationSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_delegation_settings_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, **kwargs: Any + ) -> _models.PortalSettingValidationKeyContract: + """Gets the secret validation key of the DelegationSettings. + + :param resource_group_name: The name of the resource group. The name 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: PortalSettingValidationKeyContract. The PortalSettingValidationKeyContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalSettingValidationKeyContract] = kwargs.pop("cls", None) + + _request = build_delegation_settings_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSettingValidationKeyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + _request = build_workspace_product_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, **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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + parameters: _models.ProductContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: ProductContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + 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, + parameters: _models.ProductUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + parameters: Union[_models.ProductUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: ProductUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_subscriptions: Delete existing subscriptions associated with the product or + not. Default value is None. + :paramtype delete_subscriptions: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_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, + etag=etag, + match_condition=match_condition, + delete_subscriptions=delete_subscriptions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword 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. + :paramtype expand_groups: bool + :keyword tags: Products which are part of a specific tag. Default value is None. + :paramtype tags: str + :return: An iterator like instance of ProductContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_product_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The ProductApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductApiLinkContract, response.json()) + + 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. The ProductApiLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract. The ProductApiLinkContract is compatible with MutableMapping + :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. The ProductApiLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + ProductApiLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract or JSON or IO[bytes] + :return: ProductApiLinkContract. The ProductApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_api_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductApiLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductApiLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductApiLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductApiLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The ProductGroupLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductGroupLinkContract, response.json()) + + 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. The ProductGroupLinkContract is compatible with + MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract. The ProductGroupLinkContract is compatible with + MutableMapping + :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. The ProductGroupLinkContract is compatible with + MutableMapping + :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, JSON, 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 one of the following types: + ProductGroupLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract or JSON or + IO[bytes] + :return: ProductGroupLinkContract. The ProductGroupLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_group_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductGroupLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| groupId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductGroupLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductGroupLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductGroupLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The GlobalSchemaContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GlobalSchemaContract] = kwargs.pop("cls", None) + + _request = build_workspace_global_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GlobalSchemaContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_global_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_global_schema_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GlobalSchemaContract. The + GlobalSchemaContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GlobalSchemaContract. The + GlobalSchemaContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GlobalSchemaContract. The + GlobalSchemaContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + GlobalSchemaContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GlobalSchemaContract. The + GlobalSchemaContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.GlobalSchemaContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_global_schema_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GlobalSchemaContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GlobalSchemaContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_global_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GlobalSchemaContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class UserSubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_subscription` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, user_id: str, sid: str, **kwargs: Any + ) -> _models.SubscriptionContract: + """Gets the specified Subscription entity associated with a particular 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + _request = build_user_subscription_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + user_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.SubscriptionContract"]: + """Lists the collection of subscriptions of the specified 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 + :keyword 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 |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SubscriptionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_user_subscription_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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: JSON, + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: IO[bytes] + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + SubscriptionCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters or JSON or + IO[bytes] + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_subscription_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, + app_type=app_type, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + 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, + parameters: _models.SubscriptionUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :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, + parameters: Union[_models.SubscriptionUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Is one of the following types: + SubscriptionUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_subscription_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + notify=notify, + app_type=app_type, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SubscriptionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def regenerate_primary_key( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The SubscriptionKeysContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionKeysContract] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionKeysContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The TagApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagApiLinkContract, response.json()) + + 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. The TagApiLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract. The TagApiLinkContract is compatible with MutableMapping + :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. The TagApiLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + TagApiLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract or JSON or IO[bytes] + :return: TagApiLinkContract. The TagApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_api_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagApiLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagApiLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagApiLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagApiLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The TagOperationLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagOperationLinkContract, response.json()) + + 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. The TagOperationLinkContract is compatible with + MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract. The TagOperationLinkContract is compatible with + MutableMapping + :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. The TagOperationLinkContract is compatible with + MutableMapping + :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, JSON, 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 one of the following types: + TagOperationLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract or JSON or + IO[bytes] + :return: TagOperationLinkContract. The TagOperationLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_operation_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagOperationLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| operationId + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagOperationLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagOperationLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagOperationLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The TagProductLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagProductLinkContract, response.json()) + + 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. The TagProductLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract. The TagProductLinkContract is compatible with MutableMapping + :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. The TagProductLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + TagProductLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract or JSON or IO[bytes] + :return: TagProductLinkContract. The TagProductLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_product_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagProductLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| productId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagProductLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagProductLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagProductLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiManagementOperationsOperations: + """ + .. 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_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Operation"]: + """Lists all of the available REST API operations of the Microsoft.ApiManagement provider. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The ApiManagementGatewayResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + + _request = build_api_gateway_get_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementGatewayResource, response.json()) + + 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, + parameters: Union[_models.ApiManagementGatewayResource, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_gateway_create_or_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + 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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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, JSON, 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 one of the following types: ApiManagementGatewayResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementGatewayResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_gateway_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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, JSON, 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 one of the following types: ApiManagementGatewayUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayUpdateParameters or JSON + or IO[bytes] + :return: An instance of AsyncLROPoller that returns ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementGatewayResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 _delete_initial(self, resource_group_name: str, gateway_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_gateway_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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.iter_bytes() if _decompress else response.iter_raw() + + 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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = _deserialize(_models.ApiManagementGatewayResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) -> AsyncItemPaged["_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 ApiManagementGatewayResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementGatewayResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_gateway_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementGatewayResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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) -> AsyncItemPaged["_models.ApiManagementGatewayResource"]: + """List all API Management gateways within a subscription. + + :return: An iterator like instance of ApiManagementGatewayResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementGatewayResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_gateway_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementGatewayResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_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 GatewayResourceSkuResult + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayResourceSkuResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayResourceSkuResult]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_gateway_skus_list_available_skus_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayResourceSkuResult], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 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. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + _request = build_api_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + api_id: str, + parameters: _models.ApiCreateOrUpdateParameter, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiContract]: + """Creates new or updates existing 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 parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns ApiContract. The ApiContract is compatible + with MutableMapping + :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, + api_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiContract]: + """Creates new or updates existing 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 parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns ApiContract. The ApiContract is compatible + with MutableMapping + :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, + api_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiContract]: + """Creates new or updates existing 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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns ApiContract. The ApiContract is compatible + with MutableMapping + :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, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiContract]: + """Creates new or updates existing 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 parameters: Create or update parameters. Is one of the following types: + ApiCreateOrUpdateParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns ApiContract. The ApiContract is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + api_id=api_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.ApiContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + api_id: str, + parameters: _models.ApiUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates 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 parameters: API Update Contract parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates 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 parameters: API Update Contract parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates 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 parameters: API Update Contract parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :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, + api_id: str, + parameters: Union[_models.ApiUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.ApiContract: + """Updates 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 parameters: API Update Contract parameters. Is one of the following types: + ApiUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + etag: str, + match_condition: MatchConditions, + delete_revisions: Optional[bool] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + delete_revisions=delete_revisions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + service_name: str, + api_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_revisions: Delete all revisions of the Api. Default value is None. + :paramtype delete_revisions: bool + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + delete_revisions=delete_revisions, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_service( + self, + resource_group_name: str, + service_name: 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 + ) -> AsyncItemPaged["_models.ApiContract"]: + """Lists all APIs 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword tags: Include tags in the response. Default value is None. + :paramtype tags: str + :keyword expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. + :paramtype expand_api_version_set: bool + :return: An iterator like instance of ApiContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_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, + tags=tags, + expand_api_version_set=expand_api_version_set, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_tags( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_apis: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.TagResourceContract"]: + """Lists a collection of apis associated with tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword 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 + |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| path | 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 |
| isCurrent | filter | eq | |
. Default value is + None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword include_not_tagged_apis: Include not tagged APIs. Default value is None. + :paramtype include_not_tagged_apis: bool + :return: An iterator like instance of TagResourceContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagResourceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_list_by_tags_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + include_not_tagged_apis=include_not_tagged_apis, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagResourceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_revision` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiRevision + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiRevisionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiRevisionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_revision_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiRevisionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_product` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_apis( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ProductContract"]: + """Lists all Products, which the API is part of. + + :param resource_group_name: The name of the resource group. The name is 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_product_list_by_apis_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class OperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`operation` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_tags( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_operations: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.TagResourceContract"]: + """Lists a collection of operations associated with tags. + + :param resource_group_name: The name of the resource group. The name is 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 + :keyword 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 + |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| method | 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword include_not_tagged_operations: Include not tagged Operations. Default value is None. + :paramtype include_not_tagged_operations: bool + :return: An iterator like instance of TagResourceContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagResourceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_operation_list_by_tags_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + include_not_tagged_operations=include_not_tagged_operations, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagResourceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiRevision + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiRevisionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiRevisionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_revision_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiRevisionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiManagementServiceOperations: # pylint: disable=too-many-public-methods + """ + .. 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_service` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **kwargs: Any + ) -> _models.ApiManagementServiceResource: + """Gets an API Management service 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 + :return: ApiManagementServiceResource. The ApiManagementServiceResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementServiceResource] = kwargs.pop("cls", None) + + _request = build_api_management_service_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceResource, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + parameters: _models.ApiManagementServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. + Required. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceResource, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. + Is one of the following types: ApiManagementServiceResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + parameters: _models.ApiManagementServiceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. + Required. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. + Is one of the following types: ApiManagementServiceUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters or JSON + or IO[bytes] + :return: An instance of AsyncLROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial(self, resource_group_name: str, service_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_management_service_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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, 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, service_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Deletes an existing 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 + :return: An instance of AsyncLROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementServiceResource]( + 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 + ) -> AsyncItemPaged["_models.ApiManagementServiceResource"]: + """List all API Management services 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 ApiManagementServiceResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_service_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementServiceResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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) -> AsyncItemPaged["_models.ApiManagementServiceResource"]: + """Lists all API Management services within an Azure subscription. + + :return: An iterator like instance of ApiManagementServiceResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_service_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementServiceResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _restore_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_restore_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_restore( + self, + resource_group_name: str, + service_name: str, + parameters: _models.ApiManagementServiceBackupRestoreParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup + operation. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup + operation. Required. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup + 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup + operation. Is one of the following types: ApiManagementServiceBackupRestoreParameters, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._restore_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _backup_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_backup_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_backup( + self, + resource_group_name: str, + service_name: str, + parameters: _models.ApiManagementServiceBackupRestoreParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_backup( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Required. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_backup( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_backup( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Is one of + the following types: ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._backup_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _migrate_to_stv2_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Optional[Union[_models.MigrateToStv2Contract, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_api_management_service_migrate_to_stv2_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :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[JSON] = 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: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :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, + parameters: Optional[Union[_models.MigrateToStv2Contract, JSON, 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 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. Is one of the following + types: MigrateToStv2Contract, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.MigrateToStv2Contract or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._migrate_to_stv2_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get_sso_token( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.ApiManagementServiceGetSsoTokenResult: + """Gets the Single-Sign-On token for the API Management Service which is 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 + :return: ApiManagementServiceGetSsoTokenResult. The ApiManagementServiceGetSsoTokenResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementServiceGetSsoTokenResult] = kwargs.pop("cls", None) + + _request = build_api_management_service_get_sso_token_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementServiceGetSsoTokenResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _apply_network_configuration_updates_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[ + Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, JSON, IO[bytes]] + ] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_api_management_service_apply_network_configuration_updates_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_apply_network_configuration_updates( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[_models.ApiManagementServiceApplyNetworkConfigurationParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + DNS changes. + + :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the + parameters are empty, all the regions in which the Api Management service is deployed will be + updated sequentially without incurring downtime in the region. Default value is None. + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_apply_network_configuration_updates( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + DNS changes. + + :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the + parameters are empty, all the regions in which the Api Management service is deployed will be + updated sequentially without incurring downtime in the region. Default value is None. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_apply_network_configuration_updates( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + DNS changes. + + :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the + parameters are empty, all the regions in which the Api Management service is deployed will be + updated sequentially without incurring downtime in the region. 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_apply_network_configuration_updates( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[ + Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, JSON, IO[bytes]] + ] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + DNS changes. + + :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the + parameters are empty, all the regions in which the Api Management service is deployed will be + updated sequentially without incurring downtime in the region. Is one of the following types: + ApiManagementServiceApplyNetworkConfigurationParameters, JSON, IO[bytes] Default value is None. + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters or + JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._apply_network_configuration_updates_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _refresh_hostnames_initial( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_management_service_refresh_hostnames_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_refresh_hostnames( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ApiManagementServiceResource]: + """Force Refresh the SSL certificate attached to the Custom Hostnames configured using secret from + KeyVault on 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 + :return: An instance of AsyncLROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._refresh_hostnames_initial( + resource_group_name=resource_group_name, + service_name=service_name, + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + async def check_name_availability( + self, + parameters: _models.ApiManagementServiceCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiManagementServiceNameAvailabilityResult: + """Checks availability and correctness of a name for an API Management service. + + :param parameters: The request body. Required. + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiManagementServiceNameAvailabilityResult. The + ApiManagementServiceNameAvailabilityResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ApiManagementServiceNameAvailabilityResult: + """Checks availability and correctness of a name for an API Management service. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiManagementServiceNameAvailabilityResult. The + ApiManagementServiceNameAvailabilityResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ApiManagementServiceNameAvailabilityResult: + """Checks availability and correctness of a name for an API Management service. + + :param parameters: The request body. 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: ApiManagementServiceNameAvailabilityResult. The + ApiManagementServiceNameAvailabilityResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + parameters: Union[_models.ApiManagementServiceCheckNameAvailabilityParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ApiManagementServiceNameAvailabilityResult: + """Checks availability and correctness of a name for an API Management service. + + :param parameters: The request body. Is one of the following types: + ApiManagementServiceCheckNameAvailabilityParameters, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters or JSON or + IO[bytes] + :return: ApiManagementServiceNameAvailabilityResult. The + ApiManagementServiceNameAvailabilityResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiManagementServiceNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementServiceNameAvailabilityResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_domain_ownership_identifier( + self, **kwargs: Any + ) -> _models.ApiManagementServiceGetDomainOwnershipIdentifierResult: + """Get the custom domain ownership identifier for an API Management service. + + :return: ApiManagementServiceGetDomainOwnershipIdentifierResult. The + ApiManagementServiceGetDomainOwnershipIdentifierResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementServiceGetDomainOwnershipIdentifierResult] = kwargs.pop("cls", None) + + _request = build_api_management_service_get_domain_ownership_identifier_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementServiceGetDomainOwnershipIdentifierResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_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 AllPoliciesContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AllPoliciesContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AllPoliciesContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_all_policies_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AllPoliciesContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiManagementServiceSkusOperations: + """ + .. 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_service_skus` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_available_service_skus( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ResourceSkuResult"]: + """Gets all available SKU for a given 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 + :return: An iterator like instance of ResourceSkuResult + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceSkuResult]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_service_skus_list_available_service_skus_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceSkuResult], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class NetworkStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`network_status` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> List[_models.NetworkStatusContractByLocation]: + """Gets the Connectivity Status to the external resources on which the Api Management service + depends from inside the Cloud Service. This also returns the DNS Servers as visible to the + CloudService. + + :param resource_group_name: The name of the resource group. The name 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: list of NetworkStatusContractByLocation + :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NetworkStatusContractByLocation]] = kwargs.pop("cls", None) + + _request = build_network_status_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(List[_models.NetworkStatusContractByLocation], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_by_location( + self, resource_group_name: str, service_name: str, location_name: str, **kwargs: Any + ) -> _models.NetworkStatusContract: + """Gets the Connectivity Status to the external resources on which the Api Management service + depends from inside the Cloud Service. This also returns the DNS Servers as visible to the + CloudService. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param location_name: Location in which the API Management service is deployed. This is one of + the Azure Regions like West US, East US, South Central US. Required. + :type location_name: str + :return: NetworkStatusContract. The NetworkStatusContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkStatusContract] = kwargs.pop("cls", None) + + _request = build_network_status_list_by_location_request( + resource_group_name=resource_group_name, + service_name=service_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NetworkStatusContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class OutboundNetworkDependenciesEndpointsOperations: # 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:`outbound_network_dependencies_endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.OutboundEnvironmentEndpointList: + """Gets the network endpoints of all outbound dependencies of a ApiManagement 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: OutboundEnvironmentEndpointList. The OutboundEnvironmentEndpointList is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpointList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OutboundEnvironmentEndpointList] = kwargs.pop("cls", None) + + _request = build_outbound_network_dependencies_endpoints_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OutboundEnvironmentEndpointList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PolicyDescriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy_description` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_service( + self, + resource_group_name: str, + service_name: str, + *, + scope: Optional[Union[str, _models.PolicyScopeContract]] = None, + **kwargs: Any + ) -> _models.PolicyDescriptionCollection: + """Lists all policy descriptions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword scope: Policy scope. Known values are: "Tenant", "Product", "Api", "Operation", and + "All". Default value is None. + :paramtype scope: str or ~azure.mgmt.apimanagement.models.PolicyScopeContract + :return: PolicyDescriptionCollection. The PolicyDescriptionCollection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyDescriptionCollection] = kwargs.pop("cls", None) + + _request = build_policy_description_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + scope=scope, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyDescriptionCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_policy_restriction_validations_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.OperationResultContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + +class PortalSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`portal_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.PortalSettingsCollection: + """Lists a collection of portalsettings 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 + :return: PortalSettingsCollection. The PortalSettingsCollection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalSettingsCollection] = kwargs.pop("cls", None) + + _request = build_portal_settings_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSettingsCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_tags( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_products: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.TagResourceContract"]: + """Lists a collection of products associated with tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword 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 | substringof, contains, startswith, endswith |
. + Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword include_not_tagged_products: Include not tagged Products. Default value is None. + :paramtype include_not_tagged_products: bool + :return: An iterator like instance of TagResourceContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagResourceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_list_by_tags_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + include_not_tagged_products=include_not_tagged_products, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagResourceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, **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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + _request = build_product_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: _models.ProductContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + product_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + product_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + product_id: str, + parameters: Union[_models.ProductContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: ProductContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + 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, + product_id: str, + parameters: _models.ProductUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + product_id: str, + parameters: Union[_models.ProductUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Update parameters. Is one of the following types: ProductUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + product_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_subscriptions: Delete existing subscriptions associated with the product or + not. Default value is None. + :paramtype delete_subscriptions: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + delete_subscriptions=delete_subscriptions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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, + expand_groups: Optional[bool] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ProductContract"]: + """Lists a collection of products in the specified 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword 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. + :paramtype expand_groups: bool + :keyword tags: Products which are part of a specific tag. Default value is None. + :paramtype tags: str + :return: An iterator like instance of ProductContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_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, + expand_groups=expand_groups, + tags=tags, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class QuotaByCounterKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`quota_by_counter_keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_by_service( + self, resource_group_name: str, service_name: str, quota_counter_key: str, **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Lists a collection of current quota counter periods associated with the counter-key configured + in the policy on the specified service instance. The api does not support paging yet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :return: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.QuotaCounterCollection] = kwargs.pop("cls", None) + + _request = build_quota_by_counter_keys_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaCounterCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + parameters: _models.QuotaCounterValueUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param parameters: The value of the quota counter to be applied to all quota counter periods. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param parameters: The value of the quota counter to be applied to all quota counter periods. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param parameters: The value of the quota counter to be applied to all quota counter periods. + 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: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + parameters: Union[_models.QuotaCounterValueUpdateContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param parameters: The value of the quota counter to be applied to all quota counter periods. + Is one of the following types: QuotaCounterValueUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or JSON or + IO[bytes] + :return: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QuotaCounterCollection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_quota_by_counter_keys_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaCounterCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class QuotaByPeriodKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`quota_by_period_keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, quota_counter_key: str, quota_period_key: str, **kwargs: Any + ) -> _models.QuotaCounterContract: + """Gets the value of the quota counter associated with the counter-key in the policy for the + specific period in 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :return: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.QuotaCounterContract] = kwargs.pop("cls", None) + + _request = build_quota_by_period_keys_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + quota_period_key=quota_period_key, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaCounterContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + parameters: _models.QuotaCounterValueUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterContract: + """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :param parameters: The value of the Quota counter to be applied on the specified period. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterContract: + """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :param parameters: The value of the Quota counter to be applied on the specified period. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterContract: + """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :param parameters: The value of the Quota counter to be applied on the specified period. + 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: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + parameters: Union[_models.QuotaCounterValueUpdateContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.QuotaCounterContract: + """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :param parameters: The value of the Quota counter to be applied on the specified period. Is one + of the following types: QuotaCounterValueUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or JSON or + IO[bytes] + :return: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QuotaCounterContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_quota_by_period_keys_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + quota_period_key=quota_period_key, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaCounterContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class RegionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`region` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.RegionContract"]: + """Lists all azure regions in which the service exists. + + :param resource_group_name: The name of the resource group. The name 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 RegionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RegionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RegionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_region_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RegionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`reports` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ReportRecordContract"]: + """Lists report records by 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 + :keyword filter: The filter to apply on the operation. Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_user( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ReportRecordContract"]: + """Lists report records by 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| userId | + select, filter | eq | |
| apiRegion | filter | eq | |
| productId | filter | + eq | |
| subscriptionId | filter | eq | |
| apiId | filter | eq | | +
| operationId | filter | eq | |
| callCountSuccess | select, orderBy | | + |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, + orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_user_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_operation( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ReportRecordContract"]: + """Lists report records by API Operations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | +
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| + operationId | select, filter | eq | |
| callCountSuccess | select, orderBy | | + |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, + orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ReportRecordContract"]: + """Lists report records by 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | select, filter | eq + | |
| subscriptionId | filter | eq | |
| callCountSuccess | select, orderBy | + | |
| callCountBlocked | select, orderBy | | |
| callCountFailed | + select, orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_geo( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ReportRecordContract"]: + """Lists report records by geography. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| country | select | | |
| region | select | | + |
| zip | select | | |
| apiRegion | filter | eq | |
| userId | + filter | eq | |
| productId | filter | eq | |
| subscriptionId | filter | eq + | |
| apiId | filter | eq | |
| operationId | filter | eq | |
| + callCountSuccess | select | | |
| callCountBlocked | select | | |
| + callCountFailed | select | | |
| callCountOther | select | | |
| + bandwidth | select, orderBy | | |
| cacheHitsCount | select | | |
| + cacheMissCount | select | | |
| apiTimeAvg | select | | |
| + apiTimeMin | select | | |
| apiTimeMax | select | | |
| + serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| + serviceTimeMax | select | | |
. Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ReportRecordContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_geo_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ReportRecordContract"]: + """Lists report records by 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | select, filter | eq | |
| productId | select, + filter | eq | |
| subscriptionId | select, filter | eq | |
| callCountSuccess + | select, orderBy | | |
| callCountBlocked | select, orderBy | | |
| + callCountFailed | select, orderBy | | |
| callCountOther | select, orderBy | | + |
| callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | + | |
| cacheHitsCount | select | | |
| cacheMissCount | select | | + |
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_subscription_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_time( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + interval: datetime.timedelta, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ReportRecordContract"]: + """Lists report records by Time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter, select | ge, le | |
| interval | select | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | +
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| + operationId | filter | eq | |
| callCountSuccess | select | | |
| + callCountBlocked | select | | |
| callCountFailed | select | | |
| + callCountOther | select | | |
| bandwidth | select, orderBy | | |
| + cacheHitsCount | select | | |
| cacheMissCount | select | | |
| + apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | + select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | + select | | |
| serviceTimeMax | select | | |
. Required. + :paramtype filter: str + :keyword interval: By time interval. Interval must be multiple of 15 minutes and may not be + zero. The value should be in ISO 8601 format + (`http://en.wikipedia.org/wiki/ISO_8601#Durations).This + `_ code can be used to convert TimeSpan + to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). + Required. + :paramtype interval: ~datetime.timedelta + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_time_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + interval=interval, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_request( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.RequestReportRecordContract"]: + """Lists report records by Request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| apiId | filter | eq | |
| operationId | filter | eq | + |
| productId | filter | eq | |
| userId | filter | eq | |
| apiRegion | + filter | eq | |
| subscriptionId | filter | eq | |
. Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of RequestReportRecordContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RequestReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RequestReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_request_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RequestReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class TagResourceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tag_resource` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.TagResourceContract"]: + """Lists a collection of resources associated with tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| aid | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| path | 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 |
| method | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
| urlTemplate | 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 | |
| isCurrent + | filter | eq | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagResourceContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagResourceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_resource_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagResourceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiReleaseOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_release` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 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. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + _request = build_api_release_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_release_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: _models.ApiReleaseContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + api_id: str, + release_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + api_id: str, + release_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + api_id: str, + release_id: str, + parameters: Union[_models.ApiReleaseContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: ApiReleaseContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_release_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + 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, + api_id: str, + release_id: str, + parameters: _models.ApiReleaseContract, + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Release Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Release Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Release Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + api_id: str, + release_id: str, + parameters: Union[_models.ApiReleaseContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 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: API Release Update parameters. Is one of the following types: + ApiReleaseContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_release_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_release_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| notes | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiReleaseContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiReleaseContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_release_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiReleaseContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiOperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_operation` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 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. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + _request = build_api_operation_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_operation_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: _models.OperationContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + api_id: str, + operation_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + api_id: str, + operation_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + api_id: str, + operation_id: str, + parameters: Union[_models.OperationContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: OperationContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_operation_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + 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, + api_id: str, + operation_id: str, + parameters: _models.OperationUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Operation Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Operation Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Operation Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + api_id: str, + operation_id: str, + parameters: Union[_models.OperationUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 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: API Operation Update parameters. Is one of the following types: + OperationUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_operation_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_operation_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword tags: Include tags in the response. Default value is None. + :paramtype tags: str + :return: An iterator like instance of OperationContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OperationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_operation_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + tags=tags, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OperationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiOperationPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_operation_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_api_operation_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_operation_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_operation_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_operation_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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_by_operation( + self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, **kwargs: Any + ) -> _models.PolicyCollection: + """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 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: PolicyCollection. The PolicyCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + _request = build_api_operation_policy_list_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class GraphQLApiResolverOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`graph_ql_api_resolver` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, api_id: str, resolver_id: str, **kwargs: Any + ) -> _models.ResolverContract: + """Gets the details of the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ResolverContract] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResolverContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, resolver_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the GraphQL API resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: _models.ResolverContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ResolverContract: + """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ResolverContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ResolverContract: + """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ResolverContract: + """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: Union[_models.ResolverContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ResolverContract: + """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: Create parameters. Is one of the following types: ResolverContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ResolverContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResolverContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_graph_ql_api_resolver_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResolverContract, response.json()) + + 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, + api_id: str, + resolver_id: str, + parameters: _models.ResolverUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResolverContract: + """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: GraphQL API Resolver Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ResolverUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResolverContract: + """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: GraphQL API Resolver Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResolverContract: + """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: GraphQL API Resolver Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: Union[_models.ResolverUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.ResolverContract: + """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: GraphQL API Resolver Update parameters. Is one of the following types: + ResolverUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ResolverUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResolverContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_graph_ql_api_resolver_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResolverContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ResolverContract"]: + """Lists a collection of the resolvers for the specified GraphQL 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 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 + :keyword 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 |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ResolverContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ResolverContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResolverContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_graph_ql_api_resolver_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResolverContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_schema` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 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. The SchemaContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SchemaContract] = kwargs.pop("cls", None) + + _request = build_api_schema_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SchemaContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_schema_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + parameters: Union[_models.SchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_schema_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + api_id: str, + schema_id: str, + parameters: _models.SchemaContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns SchemaContract. The SchemaContract is + compatible with MutableMapping + :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, + api_id: str, + schema_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns SchemaContract. The SchemaContract is + compatible with MutableMapping + :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, + api_id: str, + schema_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns SchemaContract. The SchemaContract is + compatible with MutableMapping + :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, + api_id: str, + schema_id: str, + parameters: Union[_models.SchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: SchemaContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns SchemaContract. The SchemaContract is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + api_id=api_id, + schema_id=schema_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.SchemaContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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( + self, + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword force: If true removes all references to the schema before deleting it. Default value + is None. + :paramtype force: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_schema_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + force=force, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| contentType + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SchemaContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SchemaContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_schema_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SchemaContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiDiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_diagnostic` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 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. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_api_diagnostic_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_diagnostic_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + api_id: str, + diagnostic_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + api_id: str, + diagnostic_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + api_id: str, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: DiagnosticContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_diagnostic_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + api_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + etag: str, + match_condition: MatchConditions, + 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 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: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 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: Diagnostic Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 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: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + api_id: str, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 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: Diagnostic Update parameters. Is one of the following types: + DiagnosticContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_diagnostic_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_diagnostic_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DiagnosticContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiagnosticContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_diagnostic_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DiagnosticContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiIssueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_issue` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + api_id: str, + issue_id: str, + *, + expand_comments_attachments: Optional[bool] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Gets the details of the Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :keyword expand_comments_attachments: Expand the comment attachments. Default value is None. + :paramtype expand_comments_attachments: bool + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IssueContract] = kwargs.pop("cls", None) + + _request = build_api_issue_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + expand_comments_attachments=expand_comments_attachments, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, issue_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: _models.IssueContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: Union[_models.IssueContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Create parameters. Is one of the following types: IssueContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IssueContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_issue_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueContract, response.json()) + + 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, + api_id: str, + issue_id: str, + parameters: _models.IssueUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IssueContract: + """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IssueContract: + """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IssueContract: + """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: Union[_models.IssueUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.IssueContract: + """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Update parameters. Is one of the following types: IssueUpdateContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IssueContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_issue_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + expand_comments_attachments: Optional[bool] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.IssueContract"]: + """Lists all issues associated with 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | + filter | eq | |
. Default value is None. + :paramtype filter: str + :keyword expand_comments_attachments: Expand the comment attachments. Default value is None. + :paramtype expand_comments_attachments: bool + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of IssueContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IssueContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_issue_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + expand_comments_attachments=expand_comments_attachments, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IssueContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiIssueCommentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_issue_comment` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, api_id: str, issue_id: str, comment_id: str, **kwargs: Any + ) -> _models.IssueCommentContract: + """Gets the details of the issue Comment 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IssueCommentContract] = kwargs.pop("cls", None) + + _request = build_api_issue_comment_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueCommentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, issue_id: str, comment_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the issue Comment 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_comment_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: _models.IssueCommentContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueCommentContract: + """Creates a new Comment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueCommentContract: + """Creates a new Comment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueCommentContract: + """Creates a new Comment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: Union[_models.IssueCommentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueCommentContract: + """Creates a new Comment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :param parameters: Create parameters. Is one of the following types: IssueCommentContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IssueCommentContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_issue_comment_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueCommentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified comment from an Issue. + + :param resource_group_name: The name of the resource group. The name is 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_comment_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.IssueCommentContract"]: + """Lists all comments for the Issue associated with 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of IssueCommentContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueCommentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IssueCommentContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_issue_comment_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IssueCommentContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiIssueAttachmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_issue_attachment` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, api_id: str, issue_id: str, attachment_id: str, **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Gets the details of the issue Attachment 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IssueAttachmentContract] = kwargs.pop("cls", None) + + _request = build_api_issue_attachment_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueAttachmentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, issue_id: str, attachment_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the issue Attachment 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_attachment_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: _models.IssueAttachmentContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Creates a new Attachment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Creates a new Attachment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Creates a new Attachment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: Union[_models.IssueAttachmentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Creates a new Attachment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :param parameters: Create parameters. Is one of the following types: IssueAttachmentContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IssueAttachmentContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_issue_attachment_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueAttachmentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified comment from an Issue. + + :param resource_group_name: The name of the resource group. The name is 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_attachment_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.IssueAttachmentContract"]: + """Lists all attachments for the Issue associated with 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of IssueAttachmentContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IssueAttachmentContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_issue_attachment_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IssueAttachmentContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiTagDescriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_tag_description` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, api_id: str, tag_description_id: str, **kwargs: Any + ) -> _models.TagDescriptionContract: + """Get Tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagDescriptionContract] = kwargs.pop("cls", None) + + _request = build_api_tag_description_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagDescriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, tag_description_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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_tag_description_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: _models.TagDescriptionCreateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.TagDescriptionContract: + """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.TagDescriptionContract: + """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.TagDescriptionContract: + """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: Union[_models.TagDescriptionCreateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.TagDescriptionContract: + """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :param parameters: Create parameters. Is one of the following types: + TagDescriptionCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagDescriptionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_tag_description_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagDescriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Delete tag description 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_tag_description_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.TagDescriptionContract"]: + """Lists all Tags descriptions in scope of API. Model similar to swagger - tagDescription is + defined on API level but tag may be assigned to the Operations. + + :param resource_group_name: The name of the resource group. The name is 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagDescriptionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagDescriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_tag_description_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagDescriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiWikiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_wiki` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, api_id: str, **kwargs: Any + ) -> _models.WikiContract: + """Gets the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + _request = build_api_wiki_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_wiki_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: _models.WikiContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: Union[_models.WikiContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Create parameters. Is one of the following types: WikiContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_wiki_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + 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, + api_id: str, + parameters: _models.WikiUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: Union[_models.WikiUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Wiki Update parameters. Is one of the following types: WikiUpdateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_wiki_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_wiki_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ApiWikisOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_wikis` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.WikiContract"]: + """Gets the wikis 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | eq | contains |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of WikiContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.WikiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WikiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_wikis_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WikiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ProductWikisOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_wikis` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + 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 + ) -> AsyncItemPaged["_models.WikiContract"]: + """Gets the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | eq | contains |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of WikiContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.WikiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WikiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_wikis_list_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WikiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiToolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_tool` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, api_id: str, tool_id: str, **kwargs: Any + ) -> _models.ToolContract: + """Gets the details of the API Tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ToolContract] = kwargs.pop("cls", None) + + _request = build_api_tool_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, tool_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_tool_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: _models.ToolContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Creates a new tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ToolContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Creates a new tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Creates a new tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: Create 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: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: Union[_models.ToolContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ToolContract: + """Creates a new tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: Create parameters. Is one of the following types: ToolContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ToolContract or JSON or IO[bytes] + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ToolContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_tool_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolContract, response.json()) + + 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, + api_id: str, + tool_id: str, + parameters: _models.ToolContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Updates the details of the tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: API Tool Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ToolContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Updates the details of the tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: API Tool Update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Updates the details of the tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: API Tool 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: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: Union[_models.ToolContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ToolContract: + """Updates the details of the tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: API Tool Update parameters. Is one of the following types: ToolContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ToolContract or JSON or IO[bytes] + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ToolContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_tool_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, service_name: str, api_id: str, tool_id: str, **kwargs: Any + ) -> None: + """Deletes the specified tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_tool_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ToolContract"]: + """Lists a collection of the MCP tools 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 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 + :keyword 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 + |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ToolContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ToolContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ToolContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_tool_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ToolContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiVersionSetOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_version_set` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 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. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + _request = build_api_version_set_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_version_set_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: _models.ApiVersionSetContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + version_set_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + version_set_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + version_set_id: str, + parameters: Union[_models.ApiVersionSetContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: + ApiVersionSetContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_version_set_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + 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, + version_set_id: str, + parameters: _models.ApiVersionSetUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 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: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 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: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 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: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + version_set_id: str, + parameters: Union[_models.ApiVersionSetUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 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: Update parameters. Is one of the following types: + ApiVersionSetUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_version_set_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_version_set_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.ApiVersionSetContract"]: + """Lists a collection of API Version Sets in the specified 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiVersionSetContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiVersionSetContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_version_set_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiVersionSetContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AuthorizationProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, authorization_provider_id: str, **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Gets the details of the authorization provider 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 authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationProviderContract] = kwargs.pop("cls", None) + + _request = build_authorization_provider_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationProviderContract, response.json()) + + 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, + authorization_provider_id: str, + parameters: _models.AuthorizationProviderContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + parameters: Union[_models.AuthorizationProviderContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param parameters: Create parameters. Is one of the following types: + AuthorizationProviderContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_provider_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationProviderContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific authorization provider from 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 authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_provider_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.AuthorizationProviderContract"]: + """Lists a collection of authorization providers 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of AuthorizationProviderContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AuthorizationProviderContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_authorization_provider_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AuthorizationProviderContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def refresh_secret( + self, resource_group_name: str, service_name: str, authorization_provider_id: str, **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Refreshes the Key Vault reference secret for the specified authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationProviderContract] = kwargs.pop("cls", None) + + _request = build_authorization_provider_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationProviderContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class AuthorizationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + authorization_provider_id: str, + authorization_id: str, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Gets the details of the authorization 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 authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationContract] = kwargs.pop("cls", None) + + _request = build_authorization_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationContract, response.json()) + + 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, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: Union[_models.AuthorizationContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Is one of the following types: AuthorizationContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific Authorization from the Authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_authorization_provider( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.AuthorizationContract"]: + """Lists a collection of authorization providers defined within a authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of AuthorizationContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AuthorizationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_authorization_list_by_authorization_provider_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AuthorizationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def confirm_consent_code( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationConfirmConsentCodeRequestContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Confirm valid consent code to suppress Authorizations anti-phishing page. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: + ~azure.mgmt.apimanagement.models.AuthorizationConfirmConsentCodeRequestContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def confirm_consent_code( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Confirm valid consent code to suppress Authorizations anti-phishing page. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def confirm_consent_code( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Confirm valid consent code to suppress Authorizations anti-phishing page. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create 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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def confirm_consent_code( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: Union[_models.AuthorizationConfirmConsentCodeRequestContract, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Confirm valid consent code to suppress Authorizations anti-phishing page. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Is one of the following types: + AuthorizationConfirmConsentCodeRequestContract, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.apimanagement.models.AuthorizationConfirmConsentCodeRequestContract or JSON or + IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_confirm_consent_code_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + +class AuthorizationLoginLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization_login_links` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationLoginRequestContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationLoginResponseContract. The AuthorizationLoginResponseContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationLoginResponseContract. The AuthorizationLoginResponseContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create 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: AuthorizationLoginResponseContract. The AuthorizationLoginResponseContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: Union[_models.AuthorizationLoginRequestContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Is one of the following types: + AuthorizationLoginRequestContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract or JSON or + IO[bytes] + :return: AuthorizationLoginResponseContract. The AuthorizationLoginResponseContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationLoginResponseContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_login_links_post_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationLoginResponseContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class AuthorizationAccessPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization_access_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Gets the details of the authorization access 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 authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationAccessPolicyContract] = kwargs.pop("cls", None) + + _request = build_authorization_access_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationAccessPolicyContract, response.json()) + + 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, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: _models.AuthorizationAccessPolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: Union[_models.AuthorizationAccessPolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :param parameters: Create parameters. Is one of the following types: + AuthorizationAccessPolicyContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationAccessPolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_access_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationAccessPolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific access policy from the Authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_access_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_authorization( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.AuthorizationAccessPolicyContract"]: + """Lists a collection of authorization access policy defined within a authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of AuthorizationAccessPolicyContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AuthorizationAccessPolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_authorization_access_policy_list_by_authorization_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AuthorizationAccessPolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class AuthorizationServerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`authorization_server` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, authsid: str, **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Gets the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationServerContract] = kwargs.pop("cls", None) + + _request = build_authorization_server_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationServerContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, authsid: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the authorizationServer 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_server_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: _models.AuthorizationServerContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Creates new authorization server or updates an existing authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Creates new authorization server or updates an existing authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Creates new authorization server or updates an existing authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: Union[_models.AuthorizationServerContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Creates new authorization server or updates an existing authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: Create or update parameters. Is one of the following types: + AuthorizationServerContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationServerContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_server_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationServerContract, response.json()) + + 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, + authsid: str, + parameters: _models.AuthorizationServerUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: OAuth2 Server settings Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: OAuth2 Server settings Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: OAuth2 Server settings Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: Union[_models.AuthorizationServerUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: OAuth2 Server settings Update parameters. Is one of the following types: + AuthorizationServerUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationServerContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_server_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationServerContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + authsid: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_server_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.AuthorizationServerContract"]: + """Lists a collection of authorization servers 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of AuthorizationServerContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AuthorizationServerContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_authorization_server_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AuthorizationServerContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_secrets( + self, resource_group_name: str, service_name: str, authsid: str, **kwargs: Any + ) -> _models.AuthorizationServerSecretsContract: + """Gets the client secret details of the authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: str + :return: AuthorizationServerSecretsContract. The AuthorizationServerSecretsContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationServerSecretsContract] = kwargs.pop("cls", None) + + _request = build_authorization_server_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationServerSecretsContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class BackendOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`backend` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + _request = build_backend_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_backend_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: _models.BackendContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + backend_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + backend_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + backend_id: str, + parameters: Union[_models.BackendContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: BackendContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backend_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + 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, + backend_id: str, + parameters: _models.BackendUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + backend_id: str, + parameters: Union[_models.BackendUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Update parameters. Is one of the following types: BackendUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backend_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_backend_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.BackendContract"]: + """Lists a collection of backends in the specified 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of BackendContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.BackendContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.BackendContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_backend_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.BackendContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def reconnect( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[_models.BackendReconnectContract] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Notifies the API Management gateway to create a new connection to the backend after the + specified timeout. If no timeout was specified, timeout of 2 minutes is used. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: 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: Reconnect request parameters. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def reconnect( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Notifies the API Management gateway to create a new connection to the backend after the + specified timeout. If no timeout was specified, timeout of 2 minutes is used. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: 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: Reconnect request parameters. Default value is None. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def reconnect( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Notifies the API Management gateway to create a new connection to the backend after the + specified timeout. If no timeout was specified, timeout of 2 minutes is used. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: 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: Reconnect request parameters. 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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def reconnect( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[Union[_models.BackendReconnectContract, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> None: + """Notifies the API Management gateway to create a new connection to the backend after the + specified timeout. If no timeout was specified, timeout of 2 minutes is used. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: 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: Reconnect request parameters. Is one of the following types: + BackendReconnectContract, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract or JSON or + IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_backend_reconnect_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class CacheOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`cache` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, cache_id: str, **kwargs: Any + ) -> _models.CacheContract: + """Gets the details of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CacheContract] = kwargs.pop("cls", None) + + _request = build_cache_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CacheContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, cache_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_cache_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: _models.CacheContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CacheContract: + """Creates or updates an External Cache to be used in Api Management 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Create or Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CacheContract: + """Creates or updates an External Cache to be used in Api Management 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Create or Update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CacheContract: + """Creates or updates an External Cache to be used in Api Management 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: Union[_models.CacheContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CacheContract: + """Creates or updates an External Cache to be used in Api Management 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Create or Update parameters. Is one of the following types: CacheContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cache_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CacheContract, response.json()) + + 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, + cache_id: str, + parameters: _models.CacheUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CacheContract: + """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CacheContract: + """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CacheContract: + """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: Union[_models.CacheUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.CacheContract: + """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Update parameters. Is one of the following types: CacheUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cache_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CacheContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific Cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_cache_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.CacheContract"]: + """Lists a collection of all external Caches in the specified 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 + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of CacheContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CacheContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CacheContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_cache_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CacheContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class CertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`certificate` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_certificate_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_certificate_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_id: str, + parameters: _models.CertificateCreateOrUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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, + certificate_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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, + certificate_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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, + certificate_id: str, + parameters: Union[_models.CertificateCreateOrUpdateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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 one of the following types: + CertificateCreateOrUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_certificate_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + certificate_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_certificate_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.CertificateContract"]: + """Lists a collection of all certificates in the specified 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword is_key_vault_refresh_failed: When set to true, the response contains only certificates + entities which failed refresh. Default value is None. + :paramtype is_key_vault_refresh_failed: bool + :return: An iterator like instance of CertificateContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CertificateContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CertificateContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_certificate_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, + is_key_vault_refresh_failed=is_key_vault_refresh_failed, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CertificateContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def refresh_secret( + self, resource_group_name: str, service_name: str, certificate_id: str, **kwargs: Any + ) -> _models.CertificateContract: + """From KeyVault, Refresh the certificate being used for authentication with the 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_certificate_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class ContentTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`content_type` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, content_type_id: str, **kwargs: Any + ) -> _models.ContentTypeContract: + """Gets the details of the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ContentTypeContract] = kwargs.pop("cls", None) + + _request = build_content_type_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContentTypeContract, response.json()) + + 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, + content_type_id: str, + parameters: _models.ContentTypeContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentTypeContract: + """Creates or updates the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Custom content types' identifiers need to start + with the ``c-`` prefix. Built-in content types can't be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentTypeContract: + """Creates or updates the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Custom content types' identifiers need to start + with the ``c-`` prefix. Built-in content types can't be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentTypeContract: + """Creates or updates the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Custom content types' identifiers need to start + with the ``c-`` prefix. Built-in content types can't be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + parameters: Union[_models.ContentTypeContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentTypeContract: + """Creates or updates the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Custom content types' identifiers need to start + with the ``c-`` prefix. Built-in content types can't be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param parameters: Create or update parameters. Is one of the following types: + ContentTypeContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ContentTypeContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_content_type_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContentTypeContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Removes the specified developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Built-in content types (with identifiers + starting with the ``c-`` prefix) can't be removed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_content_type_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ContentTypeContract"]: + """Lists the developer portal's content types. Content types describe content items' properties, + validation rules, and constraints. + + :param resource_group_name: The name of the resource group. The name 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 ContentTypeContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentTypeContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ContentTypeContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_content_type_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ContentTypeContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ContentItemOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`content_item` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, content_type_id: str, content_item_id: str, **kwargs: Any + ) -> _models.ContentItemContract: + """Returns the developer portal's content item 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 content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ContentItemContract] = kwargs.pop("cls", None) + + _request = build_content_item_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContentItemContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, content_type_id: str, content_item_id: str, **kwargs: Any + ) -> bool: + """Returns the entity state (ETag) version of the developer portal's content item 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 content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_content_item_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + parameters: _models.ContentItemContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentItemContract: + """Creates a new developer portal's content item specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ContentItemContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentItemContract: + """Creates a new developer portal's content item specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :param parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentItemContract: + """Creates a new developer portal's content item specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + parameters: Union[_models.ContentItemContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentItemContract: + """Creates a new developer portal's content item specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :param parameters: Create or update parameters. Is one of the following types: + ContentItemContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ContentItemContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ContentItemContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_content_item_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContentItemContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Removes the specified developer portal's content item. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_content_item_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, content_type_id: str, **kwargs: Any + ) -> AsyncItemPaged["_models.ContentItemContract"]: + """Lists developer portal's content items specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :return: An iterator like instance of ContentItemContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentItemContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ContentItemContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_content_item_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ContentItemContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DeletedServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`deleted_services` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get_by_name(self, service_name: str, location: str, **kwargs: Any) -> _models.DeletedServiceContract: + """Get soft-deleted Api Management Service by name. + + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: DeletedServiceContract. The DeletedServiceContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedServiceContract] = kwargs.pop("cls", None) + + _request = build_deleted_services_get_by_name_request( + service_name=service_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DeletedServiceContract, response.json()) + + 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) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_deleted_services_purge_request( + service_name=service_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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, 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_purge( + self, service_name: str, location: str, **kwargs: Any + ) -> AsyncLROPoller[_models.DeletedServiceContract]: + """Purges Api Management Service (deletes it with no option to undelete). + + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: An instance of AsyncLROPoller that returns DeletedServiceContract. The + DeletedServiceContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedServiceContract] = 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._purge_initial( + service_name=service_name, + location=location, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.DeletedServiceContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DeletedServiceContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DeletedServiceContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncItemPaged["_models.DeletedServiceContract"]: + """Lists all soft-deleted services available for undelete for the given subscription. + + :return: An iterator like instance of DeletedServiceContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedServiceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_deleted_services_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DeletedServiceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DocumentationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`documentation` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, documentation_id: str, **kwargs: Any + ) -> _models.DocumentationContract: + """Gets the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DocumentationContract] = kwargs.pop("cls", None) + + _request = build_documentation_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DocumentationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, documentation_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_documentation_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: _models.DocumentationContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.DocumentationContract: + """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DocumentationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.DocumentationContract: + """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.DocumentationContract: + """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: Union[_models.DocumentationContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.DocumentationContract: + """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Create parameters. Is one of the following types: DocumentationContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DocumentationContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DocumentationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_documentation_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DocumentationContract, response.json()) + + 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, + documentation_id: str, + parameters: _models.DocumentationUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DocumentationContract: + """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Documentation Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DocumentationUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DocumentationContract: + """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Documentation Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DocumentationContract: + """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Documentation Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: Union[_models.DocumentationUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.DocumentationContract: + """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Documentation Update parameters. Is one of the following types: + DocumentationUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DocumentationUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DocumentationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_documentation_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DocumentationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_documentation_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.DocumentationContract"]: + """Lists all Documentations 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | eq | contains |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DocumentationContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DocumentationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DocumentationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_documentation_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DocumentationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class EmailTemplateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`email_template` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + template_name: Union[str, _models.TemplateName], + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Gets the details of the email template 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 template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.EmailTemplateContract] = kwargs.pop("cls", None) + + _request = build_email_template_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EmailTemplateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the email template 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 template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_email_template_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: _models.EmailTemplateUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates an Email Template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: 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. + Known values are: "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Email Template update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates an Email Template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: 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. + Known values are: "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Email Template update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates an Email Template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: 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. + Known values are: "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Email Template 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: Union[_models.EmailTemplateUpdateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates an Email Template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: 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. + Known values are: "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Email Template update parameters. Is one of the following types: + EmailTemplateUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EmailTemplateContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_email_template_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EmailTemplateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: _models.EmailTemplateUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: Union[_models.EmailTemplateUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Update parameters. Is one of the following types: + EmailTemplateUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EmailTemplateContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_email_template_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EmailTemplateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Reset the Email Template to default template provided by 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 template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_email_template_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.EmailTemplateContract"]: + """Gets all email templates. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of EmailTemplateContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EmailTemplateContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_email_template_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EmailTemplateContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The + ApiManagementGatewayConfigConnectionResource is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementGatewayConfigConnectionResource] = kwargs.pop("cls", None) + + _request = build_api_gateway_config_connection_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementGatewayConfigConnectionResource, response.json()) + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_gateway_config_connection_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + 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 + ApiManagementGatewayConfigConnectionResource. The ApiManagementGatewayConfigConnectionResource + is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :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 + ApiManagementGatewayConfigConnectionResource. The ApiManagementGatewayConfigConnectionResource + is compatible with MutableMapping + :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 + ApiManagementGatewayConfigConnectionResource. The ApiManagementGatewayConfigConnectionResource + is compatible with MutableMapping + :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, JSON, 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 one of the following types: + ApiManagementGatewayConfigConnectionResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns + ApiManagementGatewayConfigConnectionResource. The ApiManagementGatewayConfigConnectionResource + is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementGatewayConfigConnectionResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_gateway_config_connection_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_gateway( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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 ApiManagementGatewayConfigConnectionResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementGatewayConfigConnectionResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_gateway_config_connection_list_by_gateway_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementGatewayConfigConnectionResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiGatewayHostnameBindingOperations: + """ + .. 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_hostname_binding` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get( + self, resource_group_name: str, gateway_name: str, hostname_binding_name: str, **kwargs: Any + ) -> _models.GatewayHostnameBindingResource: + """Gets an API Management gateway hostname binding 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :return: GatewayHostnameBindingResource. The GatewayHostnameBindingResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayHostnameBindingResource] = kwargs.pop("cls", None) + + _request = build_api_gateway_hostname_binding_get_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayHostnameBindingResource, response.json()) + + 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, + hostname_binding_name: str, + parameters: Union[_models.GatewayHostnameBindingResource, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_gateway_hostname_binding_create_or_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + gateway_name: str, + hostname_binding_name: str, + parameters: _models.GatewayHostnameBindingResource, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayHostnameBindingResource]: + """Creates or updates an API Management gateway hostname binding. 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway hostname + binding operation. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GatewayHostnameBindingResource. The + GatewayHostnameBindingResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayHostnameBindingResource]: + """Creates or updates an API Management gateway hostname binding. 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway hostname + binding operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GatewayHostnameBindingResource. The + GatewayHostnameBindingResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayHostnameBindingResource]: + """Creates or updates an API Management gateway hostname binding. 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway hostname + binding 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GatewayHostnameBindingResource. The + GatewayHostnameBindingResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + parameters: Union[_models.GatewayHostnameBindingResource, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GatewayHostnameBindingResource]: + """Creates or updates an API Management gateway hostname binding. 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway hostname + binding operation. Is one of the following types: GatewayHostnameBindingResource, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GatewayHostnameBindingResource. The + GatewayHostnameBindingResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayHostnameBindingResource] = 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, + hostname_binding_name=hostname_binding_name, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = _deserialize(_models.GatewayHostnameBindingResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.GatewayHostnameBindingResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.GatewayHostnameBindingResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_gateway_hostname_binding_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + hostname_binding_name: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an existing API Management gateway hostname binding. + + :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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + hostname_binding_name=hostname_binding_name, + etag=etag, + match_condition=match_condition, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_gateway( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.GatewayHostnameBindingResource"]: + """List all API Management gateway hostname bindings 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 GatewayHostnameBindingResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayHostnameBindingResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_gateway_hostname_binding_list_by_gateway_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayHostnameBindingResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _refresh_secret_initial( + self, resource_group_name: str, gateway_name: str, hostname_binding_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_gateway_hostname_binding_refresh_secret_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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]: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, gateway_name: str, hostname_binding_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Refresh the secret for an API Management gateway hostname binding. + + :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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._refresh_secret_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + +class GatewayOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, gateway_id: str, **kwargs: Any + ) -> _models.GatewayContract: + """Gets the details of the Gateway 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 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: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayContract] = kwargs.pop("cls", None) + + _request = build_gateway_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, gateway_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the Gateway 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 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: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayContract: + """Creates or updates a Gateway to be used in Api Management 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 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: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayContract: + """Creates or updates a Gateway to be used in Api Management 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 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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayContract: + """Creates or updates a Gateway to be used in Api Management 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 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: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayContract: + """Creates or updates a Gateway to be used in Api Management 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 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: Is one of the following types: GatewayContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayContract, response.json()) + + 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, + gateway_id: str, + parameters: _models.GatewayContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayContract: + """Updates the details of the gateway 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 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: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayContract: + """Updates the details of the gateway 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 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: Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayContract: + """Updates the details of the gateway 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 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: Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.GatewayContract: + """Updates the details of the gateway 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 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: Is one of the following types: GatewayContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.GatewayContract"]: + """Lists a collection of gateways registered with 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| region | + 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GatewayContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_gateway_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_keys( + self, resource_group_name: str, service_name: str, gateway_id: str, **kwargs: Any + ) -> _models.GatewayKeysContract: + """Retrieves gateway 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 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: GatewayKeysContract. The GatewayKeysContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayKeysContract] = kwargs.pop("cls", None) + + _request = build_gateway_list_keys_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayKeysContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def regenerate_key( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayKeyRegenerationRequestContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Regenerates specified gateway key invalidating any tokens created with it. + + :param resource_group_name: The name of the resource group. The name is 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: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Regenerates specified gateway key invalidating any tokens created with it. + + :param resource_group_name: The name of the resource group. The name is 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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Regenerates specified gateway key invalidating any tokens created with it. + + :param resource_group_name: The name of the resource group. The name is 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: 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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayKeyRegenerationRequestContract, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Regenerates specified gateway key invalidating any tokens created with it. + + :param resource_group_name: The name of the resource group. The name is 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: Is one of the following types: GatewayKeyRegenerationRequestContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract or + JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_regenerate_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def generate_token( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayTokenRequestContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayTokenContract: + """Gets the Shared Access Authorization Token for the 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: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayTokenContract. The GatewayTokenContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def generate_token( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayTokenContract: + """Gets the Shared Access Authorization Token for the 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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayTokenContract. The GatewayTokenContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def generate_token( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayTokenContract: + """Gets the Shared Access Authorization Token for the 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: 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: GatewayTokenContract. The GatewayTokenContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def generate_token( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayTokenRequestContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.GatewayTokenContract: + """Gets the Shared Access Authorization Token for the 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: Is one of the following types: GatewayTokenRequestContract, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract or JSON or + IO[bytes] + :return: GatewayTokenContract. The GatewayTokenContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayTokenContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_generate_token_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayTokenContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def invalidate_debug_credentials( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The GatewayDebugCredentialsContract is compatible + with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayDebugCredentialsContract. The GatewayDebugCredentialsContract is compatible + with MutableMapping + :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. The GatewayDebugCredentialsContract is compatible + with MutableMapping + :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, JSON, 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 one of the following types: + GatewayListDebugCredentialsContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContract or JSON + or IO[bytes] + :return: GatewayDebugCredentialsContract. The GatewayDebugCredentialsContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayDebugCredentialsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_list_debug_credentials_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayDebugCredentialsContract, response.json()) + + 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 + :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: JSON, + *, + 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: JSON + :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 + :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 + :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, JSON, 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 one of the following types: + GatewayListTraceContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListTraceContract or JSON or + IO[bytes] + :return: dict mapping str to any + :rtype: dict[str, any] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_list_trace_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(dict[str, Any], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class GatewayApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway_api` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + gateway_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ApiContract"]: + """Lists a collection of the APIs associated with a 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_gateway_api_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, gateway_id: str, api_id: str, **kwargs: Any + ) -> bool: + """Checks that API entity specified by identifier is associated with the Gateway 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 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_api_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + parameters: Optional[_models.AssociationContract] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Default value is None. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: 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: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + parameters: Optional[Union[_models.AssociationContract, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ApiContract: + """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Is one of the following types: AssociationContract, JSON, IO[bytes] Default + value is None. + :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract or JSON or IO[bytes] + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_gateway_api_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, service_name: str, gateway_id: str, api_id: str, **kwargs: Any + ) -> None: + """Deletes the specified API from the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_api_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class GatewayHostnameConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway_hostname_configuration` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, gateway_id: str, hc_id: str, **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Get details of a hostname configuration. + + :param resource_group_name: The name of the resource group. The name is 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayHostnameConfigurationContract] = kwargs.pop("cls", None) + + _request = build_gateway_hostname_configuration_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayHostnameConfigurationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, gateway_id: str, hc_id: str, **kwargs: Any + ) -> bool: + """Checks that hostname configuration entity specified by identifier exists for specified Gateway + 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 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_hostname_configuration_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: _models.GatewayHostnameConfigurationContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :param 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: Union[_models.GatewayHostnameConfigurationContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :param parameters: Is one of the following types: GatewayHostnameConfigurationContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayHostnameConfigurationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_hostname_configuration_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayHostnameConfigurationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified hostname configuration from the specified 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_hostname_configuration_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.GatewayHostnameConfigurationContract"]: + """Lists the collection of hostname configurations for the specified 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| hostname + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GatewayHostnameConfigurationContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayHostnameConfigurationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_gateway_hostname_configuration_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayHostnameConfigurationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class GatewayCertificateAuthorityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`gateway_certificate_authority` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, gateway_id: str, certificate_id: str, **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Get assigned Gateway Certificate Authority 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 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayCertificateAuthorityContract] = kwargs.pop("cls", None) + + _request = build_gateway_certificate_authority_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayCertificateAuthorityContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, gateway_id: str, certificate_id: str, **kwargs: Any + ) -> bool: + """Checks if Certificate entity is assigned to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_certificate_authority_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + parameters: _models.GatewayCertificateAuthorityContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Assign Certificate entity to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Assign Certificate entity to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Assign Certificate entity to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + parameters: Union[_models.GatewayCertificateAuthorityContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Assign Certificate entity to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Is one of the following types: GatewayCertificateAuthorityContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayCertificateAuthorityContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_certificate_authority_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayCertificateAuthorityContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Remove relationship between Certificate Authority and Gateway 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 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_certificate_authority_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.GatewayCertificateAuthorityContract"]: + """Lists the collection of Certificate Authorities for the specified Gateway 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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | eq, ne | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GatewayCertificateAuthorityContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayCertificateAuthorityContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_gateway_certificate_authority_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayCertificateAuthorityContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class GroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`group` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + _request = build_group_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_group_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: _models.GroupCreateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + group_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + group_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + group_id: str, + parameters: Union[_models.GroupCreateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Create parameters. Is one of the following types: GroupCreateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_group_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + 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, + group_id: str, + parameters: _models.GroupUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + group_id: str, + parameters: Union[_models.GroupUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Update parameters. Is one of the following types: GroupUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_group_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + group_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific group 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_group_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.GroupContract"]: + """Lists a collection of groups 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GroupContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GroupContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GroupContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class GroupUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`group_user` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + group_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of UserContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.UserContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_group_user_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.UserContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_group_user_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, 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 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. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + _request = build_group_user_create_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, service_name: 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 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_group_user_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of UserContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.UserContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_group_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.UserContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_group_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + _request = build_workspace_group_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_group_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class IdentityProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`identity_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + identity_provider_name: Union[str, _models.IdentityProviderType], + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Gets the configuration details of the identity Provider configured in specified 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 identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IdentityProviderContract] = kwargs.pop("cls", None) + + _request = build_identity_provider_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IdentityProviderContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the identityProvider 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 identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_identity_provider_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: _models.IdentityProviderCreateContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Creates or Updates the IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Creates or Updates the IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Creates or Updates the IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: Union[_models.IdentityProviderCreateContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Creates or Updates the IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Create parameters. Is one of the following types: + IdentityProviderCreateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IdentityProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_identity_provider_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IdentityProviderContract, response.json()) + + 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, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: _models.IdentityProviderUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: Union[_models.IdentityProviderUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Update parameters. Is one of the following types: + IdentityProviderUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IdentityProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_identity_provider_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IdentityProviderContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified identity provider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_identity_provider_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.IdentityProviderContract"]: + """Lists a collection of Identity Provider configured in the specified 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 + :return: An iterator like instance of IdentityProviderContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IdentityProviderContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_identity_provider_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IdentityProviderContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_secrets( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + **kwargs: Any + ) -> _models.ClientSecretContract: + """Gets the client secret details of the Identity Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :return: ClientSecretContract. The ClientSecretContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientSecretContract] = kwargs.pop("cls", None) + + _request = build_identity_provider_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientSecretContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class LoggerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`logger` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + _request = build_logger_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_logger_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: _models.LoggerContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + logger_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + logger_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + logger_id: str, + parameters: Union[_models.LoggerContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Create parameters. Is one of the following types: LoggerContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_logger_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + 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, + logger_id: str, + parameters: _models.LoggerUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + logger_id: str, + parameters: Union[_models.LoggerUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Update parameters. Is one of the following types: LoggerUpdateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_logger_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_logger_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.LoggerContract"]: + """Lists a collection of loggers in the specified 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of LoggerContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.LoggerContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LoggerContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_logger_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LoggerContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class NamedValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`named_value` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: NamedValueContract. The NamedValueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + + _request = build_named_value_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NamedValueContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_named_value_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + parameters: Union[_models.NamedValueCreateContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_named_value_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + named_value_id: str, + parameters: _models.NamedValueCreateContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, + named_value_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, + named_value_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, + named_value_id: str, + parameters: Union[_models.NamedValueCreateContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Is one of the following types: NamedValueCreateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + named_value_id=named_value_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + named_value_id: str, + parameters: Union[_models.NamedValueUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_named_value_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + named_value_id: str, + parameters: _models.NamedValueUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, + named_value_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, + named_value_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :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, + named_value_id: str, + parameters: Union[_models.NamedValueUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Update parameters. Is one of the following types: + NamedValueUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + named_value_id=named_value_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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 = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific named value from 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_named_value_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.NamedValueContract"]: + """Lists a collection of named values 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword is_key_vault_refresh_failed: When set to true, the response contains only named value + entities which failed refresh. Default value is None. + :paramtype is_key_vault_refresh_failed: bool + :return: An iterator like instance of NamedValueContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NamedValueContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_named_value_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, + is_key_vault_refresh_failed=is_key_vault_refresh_failed, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NamedValueContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_value( + self, resource_group_name: str, service_name: 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: NamedValueSecretContract. The NamedValueSecretContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamedValueSecretContract] = kwargs.pop("cls", None) + + _request = build_named_value_list_value_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NamedValueSecretContract, response.json()) + + 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, named_value_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_named_value_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: An instance of AsyncLROPoller that returns NamedValueContract. The NamedValueContract + is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + named_value_id=named_value_id, + 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 = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + +class NotificationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`notification` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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 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. The NotificationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_notification_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NotificationContract, response.json()) + + 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, + notification_name: Union[str, _models.NotificationName], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.NotificationContract: + """Create or Update API Management publisher 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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: NotificationContract. The NotificationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_notification_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NotificationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_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 + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of NotificationContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NotificationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NotificationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_notification_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NotificationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class NotificationRecipientUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`notification_recipient_user` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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 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. The RecipientUserCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientUserCollection] = kwargs.pop("cls", None) + + _request = build_notification_recipient_user_list_by_notification_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientUserCollection, response.json()) + + 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, + 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_notification_recipient_user_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, + 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 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. The RecipientUserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientUserContract] = kwargs.pop("cls", None) + + _request = build_notification_recipient_user_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientUserContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: 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 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_notification_recipient_user_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class NotificationRecipientEmailOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`notification_recipient_email` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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 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. The RecipientEmailCollection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientEmailCollection] = kwargs.pop("cls", None) + + _request = build_notification_recipient_email_list_by_notification_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientEmailCollection, response.json()) + + 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, + 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_notification_recipient_email_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, + 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 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. The RecipientEmailContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientEmailContract] = kwargs.pop("cls", None) + + _request = build_notification_recipient_email_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientEmailContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: 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 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_notification_recipient_email_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The RecipientUserCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientUserCollection] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientUserCollection, response.json()) + + 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: Workspace identifier. Must be unique in the current API Management + service instance. 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The RecipientUserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientUserContract] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientUserContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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: Workspace identifier. Must be unique in the current API Management + service instance. 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The RecipientEmailCollection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientEmailCollection] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_email_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientEmailCollection, response.json()) + + 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: Workspace identifier. Must be unique in the current API Management + service instance. 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_email_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The RecipientEmailContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientEmailContract] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_email_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientEmailContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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: Workspace identifier. Must be unique in the current API Management + service instance. 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_email_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class OpenIdConnectProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`open_id_connect_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, opid: str, **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Gets specific OpenID Connect Provider without secrets. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OpenidConnectProviderContract] = kwargs.pop("cls", None) + + _request = build_open_id_connect_provider_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OpenidConnectProviderContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, opid: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the openIdConnectProvider 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 opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_open_id_connect_provider_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: _models.OpenidConnectProviderContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Creates or updates the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Creates or updates the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Creates or updates the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: Union[_models.OpenidConnectProviderContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Creates or updates the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Create parameters. Is one of the following types: + OpenidConnectProviderContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenidConnectProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_open_id_connect_provider_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OpenidConnectProviderContract, response.json()) + + 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, + opid: str, + parameters: _models.OpenidConnectProviderUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Updates the specific OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Updates the specific OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Updates the specific OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: Union[_models.OpenidConnectProviderUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Updates the specific OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Update parameters. Is one of the following types: + OpenidConnectProviderUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenidConnectProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_open_id_connect_provider_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OpenidConnectProviderContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + opid: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific OpenID Connect Provider 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 opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_open_id_connect_provider_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.OpenidConnectProviderContract"]: + """Lists of all the OpenId Connect Providers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of OpenidConnectProviderContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OpenidConnectProviderContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_open_id_connect_provider_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OpenidConnectProviderContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_secrets( + self, resource_group_name: str, service_name: str, opid: str, **kwargs: Any + ) -> _models.ClientSecretContract: + """Gets the client secret details of the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :return: ClientSecretContract. The ClientSecretContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientSecretContract] = kwargs.pop("cls", None) + + _request = build_open_id_connect_provider_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientSecretContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class PolicyFragmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`policy_fragment` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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 id: A resource identifier. Required. + :type id: str + :keyword format: Policy fragment content format. Known values are: "xml" and "rawxml". Default + value is None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :return: PolicyFragmentContract. The PolicyFragmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyFragmentContract] = kwargs.pop("cls", None) + + _request = build_policy_fragment_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyFragmentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: 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 id: A resource identifier. Required. + :type id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_fragment_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + id: str, + parameters: Union[_models.PolicyFragmentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_fragment_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + id: str, + parameters: _models.PolicyFragmentContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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, + id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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, + id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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, + id: str, + parameters: Union[_models.PolicyFragmentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Is one of the following types: + PolicyFragmentContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + id=id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.PolicyFragmentContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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( + self, + resource_group_name: str, + service_name: str, + id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 id: A resource identifier. Required. + :type id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_fragment_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyFragmentContract"]: + """Gets all policy fragments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword 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. + :paramtype filter: str + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of PolicyFragmentContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyFragmentContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyFragmentContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_references( + self, + resource_group_name: str, + service_name: 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 id: A resource identifier. Required. + :type id: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: ResourceCollection. The ResourceCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ResourceCollection] = kwargs.pop("cls", None) + + _request = build_policy_fragment_list_references_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The PolicyRestrictionContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyRestrictionContract] = kwargs.pop("cls", None) + + _request = build_policy_restriction_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyRestrictionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_restriction_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + parameters: _models.PolicyRestrictionContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + PolicyRestrictionContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restriction_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyRestrictionContract, response.json()) + + 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, + parameters: _models.PolicyRestrictionUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: The policy restriction to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: The policy restriction to apply. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: The policy restriction to apply. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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, + parameters: Union[_models.PolicyRestrictionUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: The policy restriction to apply. Is one of the following types: + PolicyRestrictionUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restriction_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyRestrictionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_restriction_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_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 PolicyRestrictionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PolicyRestrictionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyRestrictionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_policy_restriction_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyRestrictionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PortalConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`portal_config` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, portal_config_id: str, **kwargs: Any + ) -> _models.PortalConfigContract: + """Get the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalConfigContract] = kwargs.pop("cls", None) + + _request = build_portal_config_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalConfigContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, portal_config_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_portal_config_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: _models.PortalConfigContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: Union[_models.PortalConfigContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Is one of the following types: + PortalConfigContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalConfigContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_portal_config_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalConfigContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: _models.PortalConfigContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: Union[_models.PortalConfigContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Is one of the following types: + PortalConfigContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalConfigContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_portal_config_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalConfigContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PortalConfigContract"]: + """Lists the developer portal configurations. + + :param resource_group_name: The name of the resource group. The name 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 PortalConfigContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PortalConfigContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PortalConfigContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_portal_config_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PortalConfigContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ClientApplicationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`client_application` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, client_application_id: str, **kwargs: Any + ) -> _models.ClientApplicationContract: + """Gets the details of the client application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :return: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientApplicationContract] = kwargs.pop("cls", None) + + _request = build_client_application_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, client_application_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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_client_application_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + parameters: _models.ClientApplicationContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationContract: + """Creates or Updates a client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationContract: + """Creates or Updates a client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationContract: + """Creates or Updates a client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_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: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + parameters: Union[_models.ClientApplicationContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ClientApplicationContract: + """Creates or Updates a client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param parameters: Create or update parameters. Is one of the following types: + ClientApplicationContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ClientApplicationContract or JSON or + IO[bytes] + :return: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClientApplicationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_client_application_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, service_name: str, client_application_id: str, **kwargs: Any + ) -> None: + """Delete client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_client_application_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.ClientApplicationContract"]: + """Lists a collection of client applications in the specified 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 + :keyword 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 + |
state | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
|. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ClientApplicationContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ClientApplicationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ClientApplicationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_client_application_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ClientApplicationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def list_secrets( + self, resource_group_name: str, service_name: str, client_application_id: str, **kwargs: Any + ) -> _models.ClientApplicationSecretsContract: + """Retrived client application secrets. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :return: ClientApplicationSecretsContract. The ClientApplicationSecretsContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientApplicationSecretsContract] = kwargs.pop("cls", None) + + _request = build_client_application_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationSecretsContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ClientApplicationProductLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`client_application_product_link` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + client_application_id: str, + client_application_product_link_id: str, + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Gets the product link for the client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :return: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientApplicationProductLinkContract] = kwargs.pop("cls", None) + + _request = build_client_application_product_link_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + client_application_product_link_id=client_application_product_link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationProductLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + parameters: _models.ClientApplicationProductLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Adds an Product to the specified Client Application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Adds an Product to the specified Client Application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Adds an Product to the specified Client Application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :param parameters: Create 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: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + parameters: Union[_models.ClientApplicationProductLinkContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Adds an Product to the specified Client Application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :param parameters: Create parameters. Is one of the following types: + ClientApplicationProductLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract or JSON + or IO[bytes] + :return: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClientApplicationProductLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_client_application_product_link_create_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + client_application_product_link_id=client_application_product_link_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationProductLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified Product from the specified client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_client_application_product_link_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + client_application_product_link_id=client_application_product_link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_client_applications( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ClientApplicationProductLinkContract"]: + """Lists a collection of product links associated with the specified client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ClientApplicationProductLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ClientApplicationProductLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_client_application_product_link_list_by_client_applications_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ClientApplicationProductLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PortalRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`portal_revision` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, portal_revision_id: str, **kwargs: Any + ) -> _models.PortalRevisionContract: + """Gets the developer portal's revision 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 portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :return: PortalRevisionContract. The PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalRevisionContract] = kwargs.pop("cls", None) + + _request = build_portal_revision_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_revision_id=portal_revision_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalRevisionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, portal_revision_id: str, **kwargs: Any + ) -> bool: + """Gets the developer portal revision 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 portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_portal_revision_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_revision_id=portal_revision_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: Union[_models.PortalRevisionContract, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_portal_revision_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_revision_id=portal_revision_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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]: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + portal_revision_id: str, + parameters: _models.PortalRevisionContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PortalRevisionContract]: + """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` + property indicates if the revision is publicly accessible. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PortalRevisionContract]: + """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` + property indicates if the revision is publicly accessible. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: JSON + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PortalRevisionContract]: + """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` + property indicates if the revision is publicly accessible. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param 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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: Union[_models.PortalRevisionContract, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PortalRevisionContract]: + """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` + property indicates if the revision is publicly accessible. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Is one of the following types: PortalRevisionContract, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalRevisionContract] = 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, + portal_revision_id=portal_revision_id, + parameters=parameters, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.PortalRevisionContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PortalRevisionContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PortalRevisionContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: Union[_models.PortalRevisionContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_portal_revision_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_revision_id=portal_revision_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + portal_revision_id: str, + parameters: _models.PortalRevisionContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PortalRevisionContract]: + """Updates the description of specified portal revision or makes it current. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PortalRevisionContract]: + """Updates the description of specified portal revision or makes it current. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PortalRevisionContract]: + """Updates the description of specified portal revision or makes it current. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: Union[_models.PortalRevisionContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> AsyncLROPoller[_models.PortalRevisionContract]: + """Updates the description of specified portal revision or makes it current. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Is one of the following types: PortalRevisionContract, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalRevisionContract] = 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, + portal_revision_id=portal_revision_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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 = _deserialize(_models.PortalRevisionContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PortalRevisionContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PortalRevisionContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @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 + ) -> AsyncItemPaged["_models.PortalRevisionContract"]: + """Lists developer portal's revisions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Supported operators | Supported functions | + |-------------|------------------------|-----------------------------------| + + |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| + |description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| + |isCurrent | eq, ne | |. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of PortalRevisionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PortalRevisionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_portal_revision_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PortalRevisionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`private_endpoint_connection` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get_by_name( + self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the details of the Private Endpoint Connection 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 private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connection_get_by_name_request( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(private_endpoint_connection_request, (IOBase, bytes)): + _content = private_endpoint_connection_request + else: + _content = json.dumps(private_endpoint_connection_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connection_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + private_endpoint_connection_name: str, + private_endpoint_connection_request: _models.PrivateEndpointConnectionRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: 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 private_endpoint_connection_name: str + :param private_endpoint_connection_request: Required. + :type private_endpoint_connection_request: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest + :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 PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: 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 private_endpoint_connection_name: str + :param private_endpoint_connection_request: Required. + :type private_endpoint_connection_request: JSON + :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 PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: 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 private_endpoint_connection_name: str + :param private_endpoint_connection_request: Required. + :type private_endpoint_connection_request: 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 PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: 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 private_endpoint_connection_name: str + :param private_endpoint_connection_request: Is one of the following types: + PrivateEndpointConnectionRequest, JSON, IO[bytes] Required. + :type private_endpoint_connection_request: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = 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, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection_request=private_endpoint_connection_request, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connection_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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, 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, service_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the specified Private Endpoint Connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + private_endpoint_connection_name=private_endpoint_connection_name, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> AsyncItemPaged["_models.PrivateEndpointConnection"]: + """Lists all private endpoint connections 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 + :return: An iterator like instance of PrivateEndpointConnection + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_private_endpoint_connection_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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_private_link_resource( + self, resource_group_name: str, service_name: str, private_link_sub_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets the private link resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param private_link_sub_resource_name: The name of the private link associated with the Azure + resource. Required. + :type private_link_sub_resource_name: str + :return: PrivateLinkResource. The PrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connection_get_private_link_resource_request( + resource_group_name=resource_group_name, + service_name=service_name, + private_link_sub_resource_name=private_link_sub_resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_private_link_resources( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources. + + :param resource_group_name: The name of the resource group. The name 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: PrivateLinkResourceListResult. The PrivateLinkResourceListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connection_list_private_link_resources_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ProductApiOperations: + """ + .. 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` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.ApiContract"]: + """Lists a collection of the APIs 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 + :keyword 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 |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_api_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, product_id: str, api_id: str, **kwargs: Any + ) -> bool: + """Checks that API entity specified by identifier is associated with the Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_api_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, product_id: str, api_id: str, **kwargs: Any + ) -> _models.ApiContract: + """Adds an API 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_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. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + _request = build_product_api_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, service_name: str, product_id: str, api_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_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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_api_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ProductGroupOperations: + """ + .. 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` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_models.GroupContract"]: + """Lists the collection of developer groups associated with 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | |
| displayName | filter | eq, ne | |
| + description | filter | eq, ne | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GroupContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GroupContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GroupContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, product_id: str, group_id: str, **kwargs: Any + ) -> bool: + """Checks that Group entity specified by identifier is associated with the Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_group_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, product_id: str, group_id: str, **kwargs: Any + ) -> _models.GroupContract: + """Adds the association between the specified developer group with 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_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + _request = build_product_group_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, resource_group_name: str, service_name: str, product_id: str, group_id: str, **kwargs: Any + ) -> None: + """Deletes the association between the specified group and 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_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_group_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ProductSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`product_subscriptions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + 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 + ) -> AsyncItemPaged["_models.SubscriptionContract"]: + """Lists the collection of subscriptions 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SubscriptionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_subscriptions_list_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The ProductApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + _request = build_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductApiLinkContract, response.json()) + + 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. The ProductApiLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract. The ProductApiLinkContract is compatible with MutableMapping + :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. The ProductApiLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + ProductApiLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract or JSON or IO[bytes] + :return: ProductApiLinkContract. The ProductApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_api_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductApiLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductApiLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductApiLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductApiLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The ProductGroupLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + _request = build_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductGroupLinkContract, response.json()) + + 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. The ProductGroupLinkContract is compatible with + MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract. The ProductGroupLinkContract is compatible with + MutableMapping + :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. The ProductGroupLinkContract is compatible with + MutableMapping + :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, JSON, 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 one of the following types: + ProductGroupLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract or JSON or + IO[bytes] + :return: ProductGroupLinkContract. The ProductGroupLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_group_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductGroupLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| groupId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductGroupLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductGroupLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductGroupLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class GlobalSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`global_schema` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: GlobalSchemaContract. The GlobalSchemaContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GlobalSchemaContract] = kwargs.pop("cls", None) + + _request = build_global_schema_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GlobalSchemaContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: 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 schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_global_schema_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_global_schema_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + schema_id: str, + parameters: _models.GlobalSchemaContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GlobalSchemaContract. The + GlobalSchemaContract is compatible with MutableMapping + :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, + schema_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GlobalSchemaContract. The + GlobalSchemaContract is compatible with MutableMapping + :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, + schema_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GlobalSchemaContract. The + GlobalSchemaContract is compatible with MutableMapping + :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, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema 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 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 one of the following types: + GlobalSchemaContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of AsyncLROPoller that returns GlobalSchemaContract. The + GlobalSchemaContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + schema_id=schema_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.GlobalSchemaContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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( + self, + resource_group_name: str, + service_name: str, + schema_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_global_schema_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_models.GlobalSchemaContract"]: + """Lists a collection of schemas registered with 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GlobalSchemaContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GlobalSchemaContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_global_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GlobalSchemaContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class TenantSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + settings_type: Union[str, _models.SettingsTypeName], + **kwargs: Any + ) -> _models.TenantSettingsContract: + """Get tenant settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param settings_type: The identifier of the settings. "public" Required. + :type settings_type: str or ~azure.mgmt.apimanagement.models.SettingsTypeName + :return: TenantSettingsContract. The TenantSettingsContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TenantSettingsContract] = kwargs.pop("cls", None) + + _request = build_tenant_settings_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + settings_type=settings_type, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TenantSettingsContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.TenantSettingsContract"]: + """Public settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: Not used. Default value is None. + :paramtype filter: str + :return: An iterator like instance of TenantSettingsContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TenantSettingsContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tenant_settings_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TenantSettingsContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class SubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`subscription` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + _request = build_subscription_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_subscription_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: _models.SubscriptionCreateParameters, + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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, + sid: str, + parameters: JSON, + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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, + sid: str, + parameters: IO[bytes], + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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, + sid: str, + parameters: Union[_models.SubscriptionCreateParameters, JSON, IO[bytes]], + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: + SubscriptionCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters or JSON or + IO[bytes] + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_subscription_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + notify=notify, + app_type=app_type, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + 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, + sid: str, + parameters: _models.SubscriptionUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :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, + sid: str, + parameters: Union[_models.SubscriptionUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Update parameters. Is one of the following types: + SubscriptionUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_subscription_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + notify=notify, + app_type=app_type, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + sid: str, + *, + etag: str, + match_condition: MatchConditions, + **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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_subscription_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.SubscriptionContract"]: + """Lists all subscriptions 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SubscriptionContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_subscription_list_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def regenerate_primary_key( + self, resource_group_name: str, service_name: str, sid: str, **kwargs: Any + ) -> None: + """Regenerates primary key of existing subscription 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_subscription_regenerate_primary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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( + self, resource_group_name: str, service_name: str, sid: str, **kwargs: Any + ) -> None: + """Regenerates secondary key of existing subscription 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_subscription_regenerate_secondary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionKeysContract. The SubscriptionKeysContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionKeysContract] = kwargs.pop("cls", None) + + _request = build_subscription_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionKeysContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The TagApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + _request = build_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagApiLinkContract, response.json()) + + 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. The TagApiLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract. The TagApiLinkContract is compatible with MutableMapping + :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. The TagApiLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + TagApiLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract or JSON or IO[bytes] + :return: TagApiLinkContract. The TagApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_api_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagApiLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagApiLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagApiLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagApiLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The TagOperationLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + _request = build_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagOperationLinkContract, response.json()) + + 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. The TagOperationLinkContract is compatible with + MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract. The TagOperationLinkContract is compatible with + MutableMapping + :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. The TagOperationLinkContract is compatible with + MutableMapping + :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, JSON, 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 one of the following types: + TagOperationLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract or JSON or + IO[bytes] + :return: TagOperationLinkContract. The TagOperationLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_operation_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagOperationLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| operationId + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagOperationLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagOperationLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagOperationLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The TagProductLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + _request = build_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagProductLinkContract, response.json()) + + 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. The TagProductLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract. The TagProductLinkContract is compatible with MutableMapping + :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. The TagProductLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + TagProductLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract or JSON or IO[bytes] + :return: TagProductLinkContract. The TagProductLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_product_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagProductLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| productId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagProductLinkContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagProductLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagProductLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class TenantAccessOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_access` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> _models.AccessInformationContract: + """Get tenant access information details without secrets. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AccessInformationContract] = kwargs.pop("cls", None) + + _request = build_tenant_access_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccessInformationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag( + self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> bool: + """Tenant access metadata. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: _models.AccessInformationCreateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: Union[_models.AccessInformationCreateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Is one of the + following types: AccessInformationCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessInformationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_access_create_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccessInformationContract, response.json()) + + 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, + access_name: Union[str, _models.AccessIdName], + parameters: _models.AccessInformationUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: Union[_models.AccessInformationUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Is one of the + following types: AccessInformationUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessInformationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_access_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccessInformationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.AccessInformationContract"]: + """Returns list of access infos - for Git and Management endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: Not used. Default value is None. + :paramtype filter: str + :return: An iterator like instance of AccessInformationContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AccessInformationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AccessInformationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tenant_access_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AccessInformationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def regenerate_primary_key( + self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> None: + """Regenerate primary access key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_regenerate_primary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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( + self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> None: + """Regenerate secondary access key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_regenerate_secondary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> _models.AccessInformationSecretsContract: + """Get tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: AccessInformationSecretsContract. The AccessInformationSecretsContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AccessInformationSecretsContract] = kwargs.pop("cls", None) + + _request = build_tenant_access_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccessInformationSecretsContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class TenantAccessGitOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_access_git` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def regenerate_primary_key( + self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> None: + """Regenerate primary access key for GIT. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_git_regenerate_primary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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( + self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> None: + """Regenerate secondary access key for GIT. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_git_regenerate_secondary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class TenantConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`tenant_configuration` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _deploy_initial( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_configuration_deploy_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_deploy( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: _models.DeployConfigurationParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation applies changes from the specified Git branch to the configuration database. + This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Deploy Configuration parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_deploy( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation applies changes from the specified Git branch to the configuration database. + This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Deploy Configuration parameters. Required. + :type parameters: JSON + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_deploy( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation applies changes from the specified Git branch to the configuration database. + This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Deploy Configuration 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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_deploy( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation applies changes from the specified Git branch to the configuration database. + This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Deploy Configuration parameters. Is one of the following types: + DeployConfigurationParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._deploy_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.OperationResultContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + async def _save_initial( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.SaveConfigurationParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_configuration_save_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_save( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: _models.SaveConfigurationParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Save Configuration parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_save( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Save Configuration parameters. Required. + :type parameters: JSON + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_save( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Save Configuration 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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_save( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.SaveConfigurationParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Save Configuration parameters. Is one of the following types: + SaveConfigurationParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._save_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.OperationResultContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + async def _validate_initial( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_configuration_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: _models.DeployConfigurationParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Validate Configuration parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Validate Configuration parameters. Required. + :type parameters: JSON + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Validate Configuration 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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationResultContract]: + """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Validate Configuration parameters. Is one of the following types: + DeployConfigurationParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or JSON or + IO[bytes] + :return: An instance of AsyncLROPoller that returns OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._validate_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.OperationResultContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + @distributed_trace_async + async def get_sync_state( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + **kwargs: Any + ) -> _models.TenantConfigurationSyncStateContract: + """Gets the status of the most recent synchronization between the configuration database and the + Git repository. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :return: TenantConfigurationSyncStateContract. The TenantConfigurationSyncStateContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TenantConfigurationSyncStateContract] = kwargs.pop("cls", None) + + _request = build_tenant_configuration_get_sync_state_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TenantConfigurationSyncStateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class UserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, user_id: str, **kwargs: Any + ) -> _models.UserContract: + """Gets the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + _request = build_user_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_entity_tag(self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_user_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: _models.UserCreateParameters, + *, + notify: Optional[bool] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.UserContract: + """Creates or Updates a 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 parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters + :keyword notify: Send an Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: JSON, + *, + notify: Optional[bool] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.UserContract: + """Creates or Updates a 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 parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword notify: Send an Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: IO[bytes], + *, + notify: Optional[bool] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.UserContract: + """Creates or Updates a 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 parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword notify: Send an Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: Union[_models.UserCreateParameters, JSON, IO[bytes]], + *, + notify: Optional[bool] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.UserContract: + """Creates or Updates a 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 parameters: Create or update parameters. Is one of the following types: + UserCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters or JSON or IO[bytes] + :keyword notify: Send an Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_user_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + notify=notify, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + 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, + user_id: str, + parameters: _models.UserUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserContract: + """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserContract: + """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserContract: + """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: Union[_models.UserUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.UserContract: + """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param parameters: Update parameters. Is one of the following types: UserUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_user_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + service_name: str, + user_id: str, + *, + etag: str, + match_condition: MatchConditions, + delete_subscriptions: Optional[bool] = None, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_user_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + delete_subscriptions=delete_subscriptions, + notify=notify, + app_type=app_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + service_name: str, + user_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_subscriptions: Whether to delete user's subscription or not. Default value is + None. + :paramtype delete_subscriptions: bool + :keyword notify: Send an Account Closed Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + delete_subscriptions=delete_subscriptions, + notify=notify, + app_type=app_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_service( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.UserContract"]: + """Lists a collection of registered users in the specified 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 + :keyword 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 + |
| state | filter | eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | + |
| note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| groups | expand | | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword expand_groups: Detailed Group in response. Default value is None. + :paramtype expand_groups: bool + :return: An iterator like instance of UserContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.UserContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_user_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, + expand_groups=expand_groups, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.UserContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def generate_sso_url( + self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any + ) -> _models.GenerateSsoUrlResult: + """Retrieves a redirection URL containing an authentication token for signing a given user into + the developer portal. + + :param resource_group_name: The name of the resource group. The name is 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 + :return: GenerateSsoUrlResult. The GenerateSsoUrlResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GenerateSsoUrlResult] = kwargs.pop("cls", None) + + _request = build_user_generate_sso_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GenerateSsoUrlResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def get_shared_access_token( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: _models.UserTokenParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserTokenResult: + """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UserTokenResult. The UserTokenResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def get_shared_access_token( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserTokenResult: + """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UserTokenResult. The UserTokenResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def get_shared_access_token( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserTokenResult: + """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token 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: UserTokenResult. The UserTokenResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def get_shared_access_token( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: Union[_models.UserTokenParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.UserTokenResult: + """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Is one of the following types: + UserTokenParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters or JSON or IO[bytes] + :return: UserTokenResult. The UserTokenResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UserTokenResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_user_get_shared_access_token_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserTokenResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class UserGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_group` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + user_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.GroupContract"]: + """Lists all user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :keyword 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 |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GroupContract + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GroupContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_user_group_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GroupContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class UserIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_identities` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any + ) -> AsyncItemPaged["_models.UserIdentityContract"]: + """List of all user identities. + + :param resource_group_name: The name of the resource group. The name is 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 + :return: An iterator like instance of UserIdentityContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserIdentityContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.UserIdentityContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_user_identities_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.UserIdentityContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class UserConfirmationPasswordOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`user_confirmation_password` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def send( + self, + resource_group_name: str, + service_name: str, + user_id: str, + *, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> None: + """Sends confirmation. + + :param resource_group_name: The name of the resource group. The name is 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 + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_user_confirmation_password_send_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + app_type=app_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The ApiManagementWorkspaceLinksResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementWorkspaceLinksResource] = kwargs.pop("cls", None) + + _request = build_api_management_workspace_link_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementWorkspaceLinksResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> AsyncItemPaged["_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 ApiManagementWorkspaceLinksResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementWorkspaceLinksResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_workspace_links_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementWorkspaceLinksResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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.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. The WorkspaceContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WorkspaceContract] = kwargs.pop("cls", None) + + _request = build_workspace_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkspaceContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, **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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + parameters: _models.WorkspaceContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: WorkspaceContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkspaceContract, response.json()) + + 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, + parameters: _models.WorkspaceContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Workspace Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Workspace Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Workspace Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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, + parameters: Union[_models.WorkspaceContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Workspace Update parameters. Is one of the following types: + WorkspaceContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkspaceContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> AsyncItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of WorkspaceContract + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.WorkspaceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WorkspaceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WorkspaceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class ApiExportOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s + :attr:`api_export` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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 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 + :keyword format: Format in which to export the Api Details to the Storage Blob with Sas Key + valid 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. + :paramtype format: str or ~azure.mgmt.apimanagement.models.ExportFormat + :keyword export: Query parameter required to export the API details. "true" Required. + :paramtype export: str or ~azure.mgmt.apimanagement.models.ExportApi + :return: ApiExportResult. The ApiExportResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiExportResult] = kwargs.pop("cls", None) + + _request = build_api_export_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + format=format, + export=export, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiExportResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ApiManagementSkusOperations: + """ + .. 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_skus` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.ApiManagementSku"]: + """Gets the list of Microsoft.ApiManagement SKUs available for your Subscription. + + :return: An iterator like instance of ApiManagementSku + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSku] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementSku]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_skus_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementSku], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + :keyword 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. + :paramtype format: str or ~azure.mgmt.apimanagement.models.ExportFormat + :keyword export: Query parameter required to export the API details. "true" Required. + :paramtype export: str or ~azure.mgmt.apimanagement.models.ExportApi + :return: ApiExportResult. The ApiExportResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiExportResult] = kwargs.pop("cls", None) + + _request = build_workspace_api_export_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiExportResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The OperationStatusResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationStatusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_operation_status_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationStatusResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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) -> 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_operations_results_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + +class _ApiManagementClientOperationsMixin( + ClientMixinABC[AsyncPipelineClient[HttpRequest, AsyncHttpResponse], ApiManagementClientConfiguration] +): + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(connectivity_check_request_params, (IOBase, bytes)): + _content = connectivity_check_request_params + else: + _content = json.dumps(connectivity_check_request_params, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_perform_connectivity_check_async_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 + ) + + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: _models.ConnectivityCheckRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectivityCheckResponse]: + """Performs a connectivity check between the API Management service and a given destination, and + returns metrics for the connection, as well as errors encountered while trying to establish it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. Required. + :type connectivity_check_request_params: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest + :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 ConnectivityCheckResponse. The + ConnectivityCheckResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectivityCheckResponse]: + """Performs a connectivity check between the API Management service and a given destination, and + returns metrics for the connection, as well as errors encountered while trying to establish it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. Required. + :type connectivity_check_request_params: JSON + :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 ConnectivityCheckResponse. The + ConnectivityCheckResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectivityCheckResponse]: + """Performs a connectivity check between the API Management service and a given destination, and + returns metrics for the connection, as well as errors encountered while trying to establish it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. Required. + :type connectivity_check_request_params: 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 ConnectivityCheckResponse. The + ConnectivityCheckResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectivityCheckResponse]: + """Performs a connectivity check between the API Management service and a given destination, and + returns metrics for the connection, as well as errors encountered while trying to establish it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. Is one of the + following types: ConnectivityCheckRequest, JSON, IO[bytes] Required. + :type connectivity_check_request_params: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns ConnectivityCheckResponse. The + ConnectivityCheckResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectivityCheckResponse] = 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._perform_connectivity_check_async_initial( + resource_group_name=resource_group_name, + service_name=service_name, + connectivity_check_request_params=connectivity_check_request_params, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ConnectivityCheckResponse, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ConnectivityCheckResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ConnectivityCheckResponse]( + 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/_operations_results_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operations_results_operations.py deleted file mode 100644 index 2c8cf6e77d66..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operations_results_operations.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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(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 = { - 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 deleted file mode 100644 index 53fb8bdd4011..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_outbound_network_dependencies_endpoints_operations.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._outbound_network_dependencies_endpoints_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class OutboundNetworkDependenciesEndpointsOperations: # 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:`outbound_network_dependencies_endpoints` 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_service( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.OutboundEnvironmentEndpointList: - """Gets the network endpoints of all outbound dependencies of a ApiManagement 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: OutboundEnvironmentEndpointList or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpointList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.OutboundEnvironmentEndpointList] = 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.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("OutboundEnvironmentEndpointList", 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/_patch.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_patch.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): 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 deleted file mode 100644 index 9bd29ff7d46f..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py +++ /dev/null @@ -1,119 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._policy_description_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PolicyDescriptionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`policy_description` 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_service( - self, - resource_group_name: str, - service_name: str, - scope: Optional[Union[str, _models.PolicyScopeContract]] = None, - **kwargs: Any - ) -> _models.PolicyDescriptionCollection: - """Lists all policy descriptions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param scope: Policy scope. Known values are: "Tenant", "Product", "Api", "Operation", and - "All". Default value is None. - :type scope: str or ~azure.mgmt.apimanagement.models.PolicyScopeContract - :return: PolicyDescriptionCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PolicyDescriptionCollection] = 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, - scope=scope, - 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("PolicyDescriptionCollection", 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/_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_fragment_operations.py deleted file mode 100644 index 3bec4879c317..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_fragment_operations.py +++ /dev/null @@ -1,682 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PolicyFragmentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - id: str, - parameters: Union[_models.PolicyFragmentContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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, - 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 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, - 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 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, - 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(self, resource_group_name: str, service_name: 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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/_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py deleted file mode 100644 index cd0400287e57..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py +++ /dev/null @@ -1,506 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_service( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> 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. - 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 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 = { - 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("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, policy_id: Union[str, _models.PolicyIdName], **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the Global policy definition 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_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 = { - 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_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, - policy_id: Union[str, _models.PolicyIdName], - format: Union[str, _models.PolicyExportFormat] = "xml", - **kwargs: Any - ) -> _models.PolicyContract: - """Get the Global policy definition 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_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 = { - 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, - 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, - 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 the global policy 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_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, - 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 the global policy 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_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, - policy_id: Union[str, _models.PolicyIdName], - parameters: Union[_models.PolicyContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.PolicyContract: - """Creates or updates the global policy 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_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 = { - 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, - 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( - self, - resource_group_name: str, - service_name: str, - policy_id: Union[str, _models.PolicyIdName], - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the global policy 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_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 = { - 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_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/_policy_restriction_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_operations.py deleted file mode 100644 index 1b0806cfc831..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_operations.py +++ /dev/null @@ -1,655 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 3f6e6151f067..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_restriction_validations_operations.py +++ /dev/null @@ -1,175 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 deleted file mode 100644 index cd945ce89aae..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_config_operations.py +++ /dev/null @@ -1,582 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._portal_config_operations import ( - build_create_or_update_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PortalConfigOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`portal_config` 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.PortalConfigContract"]: - """Lists the developer portal configurations. - - :param resource_group_name: The name of the resource group. The name 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 PortalConfigContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PortalConfigContract] - :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.PortalConfigCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("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( - self, resource_group_name: str, service_name: str, portal_config_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - portal_config_id=portal_config_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, portal_config_id: str, **kwargs: Any - ) -> _models.PortalConfigContract: - """Get the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_id: str - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalConfigContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_config_id=portal_config_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("PortalConfigContract", 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, - portal_config_id: str, - if_match: str, - parameters: _models.PortalConfigContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalConfigContract: - """Update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalConfigContract: - """Update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. 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: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: Union[_models.PortalConfigContract, IO[bytes]], - **kwargs: Any - ) -> _models.PortalConfigContract: - """Update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. Is either a PortalConfigContract - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract or IO[bytes] - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalConfigContract] = 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, "PortalConfigContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_config_id=portal_config_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) - - deserialized = self._deserialize("PortalConfigContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: _models.PortalConfigContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalConfigContract: - """Create or update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalConfigContract: - """Create or update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. 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: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: Union[_models.PortalConfigContract, IO[bytes]], - **kwargs: Any - ) -> _models.PortalConfigContract: - """Create or update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. Is either a PortalConfigContract - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract or IO[bytes] - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalConfigContract] = 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, "PortalConfigContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_config_id=portal_config_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) - - deserialized = self._deserialize("PortalConfigContract", 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/_portal_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py deleted file mode 100644 index 0bf334a9d9c0..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_revision_operations.py +++ /dev/null @@ -1,777 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._portal_revision_operations import ( - build_create_or_update_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PortalRevisionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`portal_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, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PortalRevisionContract"]: - """Lists developer portal's revisions. - - :param resource_group_name: The name of the resource group. The name is 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: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - - Supported functions - * - - - - |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| - |description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| - |isCurrent | 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 - :return: An iterator like instance of either PortalRevisionContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :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.PortalRevisionCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("PortalRevisionCollection", 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, portal_revision_id: str, **kwargs: Any - ) -> bool: - """Gets the developer portal revision 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 portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - portal_revision_id=portal_revision_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, portal_revision_id: str, **kwargs: Any - ) -> _models.PortalRevisionContract: - """Gets the developer portal's revision 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 portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :return: PortalRevisionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalRevisionContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_revision_id=portal_revision_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("PortalRevisionContract", 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, - portal_revision_id: str, - parameters: Union[_models.PortalRevisionContract, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, "PortalRevisionContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_revision_id=portal_revision_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) - - _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]: - 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, - portal_revision_id: str, - parameters: _models.PortalRevisionContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PortalRevisionContract]: - """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` - property indicates if the revision is publicly accessible. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract - :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 PortalRevisionContract or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PortalRevisionContract]: - """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` - property indicates if the revision is publicly accessible. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :param 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 PortalRevisionContract or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - parameters: Union[_models.PortalRevisionContract, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PortalRevisionContract]: - """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` - property indicates if the revision is publicly accessible. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :param parameters: Is either a PortalRevisionContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PortalRevisionContract or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :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.PortalRevisionContract] = 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, - portal_revision_id=portal_revision_id, - 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")) - 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.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.PortalRevisionContract].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PortalRevisionContract]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _update_initial( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - if_match: str, - parameters: Union[_models.PortalRevisionContract, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, "PortalRevisionContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_revision_id=portal_revision_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, - portal_revision_id: str, - if_match: str, - parameters: _models.PortalRevisionContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PortalRevisionContract]: - """Updates the description of specified portal revision or makes it current. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract - :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 PortalRevisionContract or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PortalRevisionContract]: - """Updates the description of specified portal revision or makes it current. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_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: 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 PortalRevisionContract or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - if_match: str, - parameters: Union[_models.PortalRevisionContract, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PortalRevisionContract]: - """Updates the description of specified portal revision or makes it current. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_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: Is either a PortalRevisionContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PortalRevisionContract or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :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.PortalRevisionContract] = 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, - portal_revision_id=portal_revision_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("PortalRevisionContract", 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.PortalRevisionContract].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PortalRevisionContract]( - 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_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py deleted file mode 100644 index 16e87d348f65..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_portal_settings_operations.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._portal_settings_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PortalSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`portal_settings` 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_service( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.PortalSettingsCollection: - """Lists a collection of portalsettings 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 - :return: PortalSettingsCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSettingsCollection] = 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.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("PortalSettingsCollection", 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/_private_endpoint_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py deleted file mode 100644 index ef470b0dab26..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_private_endpoint_connection_operations.py +++ /dev/null @@ -1,662 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._private_endpoint_connection_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_by_name_request, - build_get_private_link_resource_request, - build_list_by_service_request, - build_list_private_link_resources_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PrivateEndpointConnectionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`private_endpoint_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_service( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - """Lists all private endpoint connections 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 - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - :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.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return 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_by_name( - self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets the details of the Private Endpoint Connection 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 private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_by_name_request( - resource_group_name=resource_group_name, - service_name=service_name, - private_endpoint_connection_name=private_endpoint_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("PrivateEndpointConnection", 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, - service_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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(private_endpoint_connection_request, (IOBase, bytes)): - _content = private_endpoint_connection_request - else: - _json = self._serialize.body(private_endpoint_connection_request, "PrivateEndpointConnectionRequest") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - private_endpoint_connection_name=private_endpoint_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, 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_create_or_update( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection_request: _models.PrivateEndpointConnectionRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection_request: Required. - :type private_endpoint_connection_request: - ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest - :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 PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection_request: Required. - :type private_endpoint_connection_request: 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 PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection_request: Is either a PrivateEndpointConnectionRequest type - or a IO[bytes] type. Required. - :type private_endpoint_connection_request: - ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - :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.PrivateEndpointConnection] = 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, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection_request=private_endpoint_connection_request, - 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("PrivateEndpointConnection", 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.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - service_name=service_name, - private_endpoint_connection_name=private_endpoint_connection_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, 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, service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes the specified Private Endpoint Connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: 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, - service_name=service_name, - private_endpoint_connection_name=private_endpoint_connection_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): # 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 - - @distributed_trace_async - async def list_private_link_resources( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources. - - :param resource_group_name: The name of the resource group. The name 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: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResourceListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_private_link_resources_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) - - _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("PrivateLinkResourceListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_private_link_resource( - self, resource_group_name: str, service_name: str, private_link_sub_resource_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets the private link resources. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param private_link_sub_resource_name: Name of the private link resource. Required. - :type private_link_sub_resource_name: str - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_private_link_resource_request( - resource_group_name=resource_group_name, - service_name=service_name, - private_link_sub_resource_name=private_link_sub_resource_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("PrivateLinkResource", 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/_product_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_link_operations.py deleted file mode 100644 index a7d4f814c7b2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_link_operations.py +++ /dev/null @@ -1,459 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 8f147a231cec..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py +++ /dev/null @@ -1,363 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._product_api_operations import ( - build_check_entity_exists_request, - build_create_or_update_request, - build_delete_request, - build_list_by_product_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProductApiOperations: - """ - .. 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` 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.ApiContract"]: - """Lists a collection of the APIs 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 |
|-------------|-------------|-------------|-------------|
| 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 |
. 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 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 = { - 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("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 check_entity_exists( - self, resource_group_name: str, service_name: str, product_id: str, api_id: str, **kwargs: Any - ) -> bool: - """Checks that API entity specified by identifier is associated with the Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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 = { - 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, - product_id=product_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 [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 - return 200 <= response.status_code <= 299 - - @distributed_trace_async - async def create_or_update( - self, resource_group_name: str, service_name: str, product_id: str, api_id: str, **kwargs: Any - ) -> _models.ApiContract: - """Adds an API 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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 = { - 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_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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, 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("ApiContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, resource_group_name: str, service_name: str, product_id: str, api_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_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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_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, 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_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_link_operations.py deleted file mode 100644 index c423d677c8d2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_link_operations.py +++ /dev/null @@ -1,459 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index d6b614d9abf1..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py +++ /dev/null @@ -1,359 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._product_group_operations import ( - build_check_entity_exists_request, - build_create_or_update_request, - build_delete_request, - build_list_by_product_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProductGroupOperations: - """ - .. 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` 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.GroupContract"]: - """Lists the collection of developer groups associated with 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | |
| displayName | filter | eq, ne | |
| - description | 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 - :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 = { - 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("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 check_entity_exists( - self, resource_group_name: str, service_name: str, product_id: str, group_id: str, **kwargs: Any - ) -> bool: - """Checks that Group entity specified by identifier is associated with the Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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 = { - 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, - product_id=product_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 [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 - return 200 <= response.status_code <= 299 - - @distributed_trace_async - async def create_or_update( - self, resource_group_name: str, service_name: str, product_id: str, group_id: str, **kwargs: Any - ) -> _models.GroupContract: - """Adds the association between the specified developer group with 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_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 = { - 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_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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, 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("GroupContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete( - self, resource_group_name: str, service_name: str, product_id: str, group_id: str, **kwargs: Any - ) -> None: - """Deletes the association between the specified group and 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_id: Group identifier. Must be unique in the current API Management service - instance. Required. - :type group_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_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, 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_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py deleted file mode 100644 index 35f7894e8ab5..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py +++ /dev/null @@ -1,809 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_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_by_tags_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProductOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - 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 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, - resource_group_name: str, - service_name: 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 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 = { - 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, - 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 - - @distributed_trace - def list_by_tags( - self, - resource_group_name: str, - service_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - include_not_tagged_products: Optional[bool] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TagResourceContract"]: - """Lists a collection of products associated with tags. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| 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 | 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 include_not_tagged_products: Include not tagged Products. Default value is None. - :type include_not_tagged_products: bool - :return: An iterator like instance of either TagResourceContract or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :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.TagResourceCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_tags_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - include_not_tagged_products=include_not_tagged_products, - 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("TagResourceCollection", 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/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py deleted file mode 100644 index 7ffd980975bc..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py +++ /dev/null @@ -1,541 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProductPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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 - def list_by_product( - self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any - ) -> 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. - 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 - :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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, - resource_group_name: str, - service_name: 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 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 = { - 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, - 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/_product_subscriptions_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py deleted file mode 100644 index 5fe22cee8f23..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py +++ /dev/null @@ -1,171 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._product_subscriptions_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProductSubscriptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`product_subscriptions` 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, - product_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionContract"]: - """Lists the collection of subscriptions 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 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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("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) 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 deleted file mode 100644 index 14844ac94543..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wiki_operations.py +++ /dev/null @@ -1,567 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._product_wiki_operations import ( - build_create_or_update_request, - build_delete_request, - build_get_entity_tag_request, - build_get_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProductWikiOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`product_wiki` 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_entity_tag(self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the Wiki for a 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 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 = { - 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, - 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, product_id: str, **kwargs: Any - ) -> _models.WikiContract: - """Gets the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_id: str - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("WikiContract", 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, - parameters: _models.WikiContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiContract - :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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - parameters: Union[_models.WikiContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_id: str - :param parameters: Create parameters. Is either a WikiContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiContract 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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = 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, "WikiContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("WikiContract", 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, - product_id: str, - if_match: str, - parameters: _models.WikiUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki for a 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 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: Wiki Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki for a 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 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: Wiki 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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - if_match: str, - parameters: Union[_models.WikiUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki for a 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 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: Wiki Update parameters. Is either a WikiUpdateContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract or IO[bytes] - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = 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, "WikiUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("WikiContract", 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( - self, resource_group_name: str, service_name: str, product_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified Wiki from 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 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 = { - 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, - 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/_product_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wikis_operations.py deleted file mode 100644 index 574fb5d2d9af..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_wikis_operations.py +++ /dev/null @@ -1,161 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._product_wikis_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ProductWikisOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`product_wikis` 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, - product_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.WikiContract"]: - """Gets the details of the Wiki for a 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 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | eq | contains |
. 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 WikiContract or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.WikiContract] - :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.WikiCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("WikiCollection", 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/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py deleted file mode 100644 index c8679ddfc692..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py +++ /dev/null @@ -1,278 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._quota_by_counter_keys_operations import 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class QuotaByCounterKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`quota_by_counter_keys` 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_service( - self, resource_group_name: str, service_name: str, quota_counter_key: str, **kwargs: Any - ) -> _models.QuotaCounterCollection: - """Lists a collection of current quota counter periods associated with the counter-key configured - in the policy on the specified service instance. The api does not support paging yet. - - .. seealso:: - - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-product-with-rules#a-namepolicies-ato-configure-call-rate-limit-and-quota-policies - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :return: QuotaCounterCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.QuotaCounterCollection] = kwargs.pop("cls", None) - - _request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - quota_counter_key=quota_counter_key, - 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("QuotaCounterCollection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - parameters: _models.QuotaCounterValueUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.QuotaCounterCollection: - """Updates all the quota counter values specified with the existing quota counter key to a value - in the specified service instance. This should be used for reset of the quota counter values. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param parameters: The value of the quota counter to be applied to all quota counter periods. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: QuotaCounterCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.QuotaCounterCollection: - """Updates all the quota counter values specified with the existing quota counter key to a value - in the specified service instance. This should be used for reset of the quota counter values. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param parameters: The value of the quota counter to be applied to all quota counter periods. - 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: QuotaCounterCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - parameters: Union[_models.QuotaCounterValueUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.QuotaCounterCollection: - """Updates all the quota counter values specified with the existing quota counter key to a value - in the specified service instance. This should be used for reset of the quota counter values. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param parameters: The value of the quota counter to be applied to all quota counter periods. - Is either a QuotaCounterValueUpdateContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or IO[bytes] - :return: QuotaCounterCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.QuotaCounterCollection] = 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, "QuotaCounterValueUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - quota_counter_key=quota_counter_key, - 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("QuotaCounterCollection", 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/_quota_by_period_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py deleted file mode 100644 index ec3163d5d8b2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py +++ /dev/null @@ -1,288 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._quota_by_period_keys_operations import build_get_request, build_update_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class QuotaByPeriodKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`quota_by_period_keys` 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, quota_counter_key: str, quota_period_key: str, **kwargs: Any - ) -> _models.QuotaCounterContract: - """Gets the value of the quota counter associated with the counter-key in the policy for the - specific period in service instance. - - .. seealso:: - - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-product-with-rules#a-namepolicies-ato-configure-call-rate-limit-and-quota-policies - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param quota_period_key: Quota period key identifier. Required. - :type quota_period_key: str - :return: QuotaCounterContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.QuotaCounterContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - quota_counter_key=quota_counter_key, - quota_period_key=quota_period_key, - 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("QuotaCounterContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - quota_period_key: str, - parameters: _models.QuotaCounterValueUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.QuotaCounterContract: - """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param quota_period_key: Quota period key identifier. Required. - :type quota_period_key: str - :param parameters: The value of the Quota counter to be applied on the specified period. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: QuotaCounterContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - quota_period_key: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.QuotaCounterContract: - """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param quota_period_key: Quota period key identifier. Required. - :type quota_period_key: str - :param parameters: The value of the Quota counter to be applied on the specified period. - 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: QuotaCounterContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - quota_period_key: str, - parameters: Union[_models.QuotaCounterValueUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.QuotaCounterContract: - """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param quota_period_key: Quota period key identifier. Required. - :type quota_period_key: str - :param parameters: The value of the Quota counter to be applied on the specified period. Is - either a QuotaCounterValueUpdateContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or IO[bytes] - :return: QuotaCounterContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.QuotaCounterContract] = 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, "QuotaCounterValueUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - quota_counter_key=quota_counter_key, - quota_period_key=quota_period_key, - 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("QuotaCounterContract", 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/_region_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py deleted file mode 100644 index efb82fa92e34..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py +++ /dev/null @@ -1,140 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._region_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RegionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`region` 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.RegionContract"]: - """Lists all azure regions in which the service exists. - - :param resource_group_name: The name of the resource group. The name 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 RegionContract or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RegionContract] - :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.RegionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("RegionListResult", 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/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py deleted file mode 100644 index 63a13f22666b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py +++ /dev/null @@ -1,981 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, 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._reports_operations import ( - build_list_by_api_request, - build_list_by_geo_request, - build_list_by_operation_request, - build_list_by_product_request, - build_list_by_request_request, - build_list_by_subscription_request, - build_list_by_time_request, - build_list_by_user_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ReportsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`reports` 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, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ReportRecordContract"]: - """Lists report records by 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 filter: The filter to apply on the operation. Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_user( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ReportRecordContract"]: - """Lists report records by 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| displayName | select, orderBy | | |
| userId | - select, filter | eq | |
| apiRegion | filter | eq | |
| productId | filter | - eq | |
| subscriptionId | filter | eq | |
| apiId | filter | eq | | -
| operationId | filter | eq | |
| callCountSuccess | select, orderBy | | - |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, - orderBy | | |
| callCountOther | select, orderBy | | |
| - callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | select | | | -
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | -
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. - Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_user_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_operation( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ReportRecordContract"]: - """Lists report records by API Operations. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | - filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | -
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| - operationId | select, filter | eq | |
| callCountSuccess | select, orderBy | | - |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, - orderBy | | |
| callCountOther | select, orderBy | | |
| - callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | select | | | -
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | -
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. - Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_product( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ReportRecordContract"]: - """Lists report records by 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | - filter | eq | |
| userId | filter | eq | |
| productId | select, filter | eq - | |
| subscriptionId | filter | eq | |
| callCountSuccess | select, orderBy | - | |
| callCountBlocked | select, orderBy | | |
| callCountFailed | - select, orderBy | | |
| callCountOther | select, orderBy | | |
| - callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | select | | | -
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | -
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. - Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_geo( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ReportRecordContract"]: - """Lists report records by geography. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| country | select | | |
| region | select | | - |
| zip | select | | |
| apiRegion | filter | eq | |
| userId | - filter | eq | |
| productId | filter | eq | |
| subscriptionId | filter | eq - | |
| apiId | filter | eq | |
| operationId | filter | eq | |
| - callCountSuccess | select | | |
| callCountBlocked | select | | |
| - callCountFailed | select | | |
| callCountOther | select | | |
| - bandwidth | select, orderBy | | |
| cacheHitsCount | select | | |
| - cacheMissCount | select | | |
| apiTimeAvg | select | | |
| - apiTimeMin | select | | |
| apiTimeMax | select | | |
| - serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| - serviceTimeMax | select | | |
. Required. - :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 ReportRecordContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_geo_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("ReportCollection", 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_by_subscription( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ReportRecordContract"]: - """Lists report records by 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | - filter | eq | |
| userId | select, filter | eq | |
| productId | select, - filter | eq | |
| subscriptionId | select, filter | eq | |
| callCountSuccess - | select, orderBy | | |
| callCountBlocked | select, orderBy | | |
| - callCountFailed | select, orderBy | | |
| callCountOther | select, orderBy | | - |
| callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | - | |
| cacheHitsCount | select | | |
| cacheMissCount | select | | - |
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | -
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. - Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_subscription_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_time( - self, - resource_group_name: str, - service_name: str, - filter: str, - interval: datetime.timedelta, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.ReportRecordContract"]: - """Lists report records by Time. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| timestamp | - filter, select | ge, le | |
| interval | select | | |
| apiRegion | - filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | -
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| - operationId | filter | eq | |
| callCountSuccess | select | | |
| - callCountBlocked | select | | |
| callCountFailed | select | | |
| - callCountOther | select | | |
| bandwidth | select, orderBy | | |
| - cacheHitsCount | select | | |
| cacheMissCount | select | | |
| - apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | - select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | - select | | |
| serviceTimeMax | select | | |
. Required. - :type filter: str - :param interval: By time interval. Interval must be multiple of 15 minutes and may not be zero. - The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This - code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new - TimeSpan(hours, minutes, seconds)). Required. - :type interval: ~datetime.timedelta - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_time_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - interval=interval, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_request( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RequestReportRecordContract"]: - """Lists report records by Request. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| apiId | filter | eq | |
| operationId | filter | eq | - |
| productId | filter | eq | |
| userId | filter | eq | |
| apiRegion | - filter | eq | |
| subscriptionId | filter | eq | |
. Required. - :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 RequestReportRecordContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RequestReportRecordContract] - :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.RequestReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_request_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("RequestReportCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return 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/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py deleted file mode 100644 index 19b18f81a5bb..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py +++ /dev/null @@ -1,458 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._sign_in_settings_operations import ( - build_create_or_update_request, - build_get_entity_tag_request, - build_get_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SignInSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`sign_in_settings` 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_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the SignInSettings. - - :param resource_group_name: The name of the resource group. The name 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: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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, **kwargs: Any) -> _models.PortalSigninSettings: - """Get Sign In Settings for the Portal. - - :param resource_group_name: The name of the resource group. The name 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: PortalSigninSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSigninSettings] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("PortalSigninSettings", 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, - if_match: str, - parameters: _models.PortalSigninSettings, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-In settings. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-In settings. 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: Union[_models.PortalSigninSettings, IO[bytes]], - **kwargs: Any - ) -> None: - """Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-In settings. Is either a PortalSigninSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "PortalSigninSettings") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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 [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 create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: _models.PortalSigninSettings, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalSigninSettings: - """Create or Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :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: PortalSigninSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalSigninSettings: - """Create or Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is 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: 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: PortalSigninSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.PortalSigninSettings, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.PortalSigninSettings: - """Create or Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is either a PortalSigninSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings 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: PortalSigninSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSigninSettings] = 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, "PortalSigninSettings") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - deserialized = self._deserialize("PortalSigninSettings", 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/_sign_up_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py deleted file mode 100644 index 6702258170b6..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py +++ /dev/null @@ -1,458 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._sign_up_settings_operations import ( - build_create_or_update_request, - build_get_entity_tag_request, - build_get_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SignUpSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`sign_up_settings` 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_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the SignUpSettings. - - :param resource_group_name: The name of the resource group. The name 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: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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, **kwargs: Any) -> _models.PortalSignupSettings: - """Get Sign Up Settings for the Portal. - - :param resource_group_name: The name of the resource group. The name 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: PortalSignupSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSignupSettings] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("PortalSignupSettings", 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, - if_match: str, - parameters: _models.PortalSignupSettings, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-Up settings. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-Up settings. 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: Union[_models.PortalSignupSettings, IO[bytes]], - **kwargs: Any - ) -> None: - """Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-Up settings. Is either a PortalSignupSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "PortalSignupSettings") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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 [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 create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: _models.PortalSignupSettings, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalSignupSettings: - """Create or Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :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: PortalSignupSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalSignupSettings: - """Create or Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is 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: 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: PortalSignupSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.PortalSignupSettings, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.PortalSignupSettings: - """Create or Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is either a PortalSignupSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings 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: PortalSignupSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSignupSettings] = 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, "PortalSignupSettings") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - deserialized = self._deserialize("PortalSignupSettings", 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/_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py deleted file mode 100644 index 7139573c106e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py +++ /dev/null @@ -1,941 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class SubscriptionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionContract"]: - """Lists all subscriptions 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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(self, resource_group_name: str, service_name: 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: str, sid: str, **kwargs: Any - ) -> None: - """Regenerates primary key of existing subscription 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: str, sid: str, **kwargs: Any - ) -> None: - """Regenerates secondary key of existing subscription 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 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 = { - 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, - 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, 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 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 = { - 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, - 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/_tag_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_api_link_operations.py deleted file mode 100644 index d9889610cbdf..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_api_link_operations.py +++ /dev/null @@ -1,458 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 8503afc71b88..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operation_link_operations.py +++ /dev/null @@ -1,459 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 2c818b1ede0d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py +++ /dev/null @@ -1,1829 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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_operations import ( - build_assign_to_api_request, - build_assign_to_operation_request, - build_assign_to_product_request, - build_create_or_update_request, - build_delete_request, - build_detach_from_api_request, - build_detach_from_operation_request, - build_detach_from_product_request, - build_get_by_api_request, - build_get_by_operation_request, - build_get_by_product_request, - build_get_entity_state_by_api_request, - build_get_entity_state_by_operation_request, - build_get_entity_state_by_product_request, - build_get_entity_state_request, - build_get_request, - build_list_by_api_request, - build_list_by_operation_request, - build_list_by_product_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TagOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_operation( - self, - resource_group_name: str, - service_name: str, - api_id: str, - operation_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TagContract"]: - """Lists all Tags associated with the 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 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| 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 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 = { - 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, - api_id=api_id, - operation_id=operation_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("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_by_operation( - self, resource_group_name: str, service_name: str, api_id: str, operation_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 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 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 = { - 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_by_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - operation_id=operation_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_by_operation( - self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Get tag associated with the 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 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 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 = { - 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_by_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - operation_id=operation_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 - - @distributed_trace_async - async def assign_to_operation( - self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Assign tag to the 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 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 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 = { - 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_assign_to_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - operation_id=operation_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, 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("TagContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def detach_from_operation( - self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any - ) -> None: - """Detach the tag from the 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. - Required. - :type tag_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_detach_from_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - operation_id=operation_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, 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_by_api( - self, - resource_group_name: str, - service_name: str, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TagContract"]: - """Lists all Tags associated with 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 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 |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| 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 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 = { - 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, - 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("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_by_api( - self, resource_group_name: str, service_name: str, api_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 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 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 = { - 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_by_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_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_by_api( - self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Get tag associated with 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 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 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 = { - 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_by_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_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 - - @distributed_trace_async - async def assign_to_api( - self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Assign tag to 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 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 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 = { - 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_assign_to_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_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, 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 - - @distributed_trace_async - async def detach_from_api( - self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any - ) -> None: - """Detach the tag from 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. - Required. - :type tag_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_detach_from_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_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, 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_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.TagContract"]: - """Lists all Tags associated with 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| 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 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 = { - 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("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_by_product( - self, resource_group_name: str, service_name: str, product_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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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 = { - 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_by_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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_by_product( - self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Get tag associated with 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 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 = { - 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_by_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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 - - @distributed_trace_async - async def assign_to_product( - self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Assign tag to 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 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 = { - 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_assign_to_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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, 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("TagContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def detach_from_product( - self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any - ) -> None: - """Detach the tag from 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. - Required. - :type tag_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_detach_from_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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, 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_by_service( - self, - resource_group_name: str, - service_name: 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 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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( - self, resource_group_name: str, service_name: str, tag_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific tag 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 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 = { - 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, - 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/_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_product_link_operations.py deleted file mode 100644 index 5f4b903b31a1..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_product_link_operations.py +++ /dev/null @@ -1,459 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 9d0bbee438a1..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py +++ /dev/null @@ -1,169 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._tag_resource_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TagResourceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`tag_resource` 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.TagResourceContract"]: - """Lists a collection of resources associated with tags. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| aid | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| - displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| path | 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 |
| method | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| urlTemplate | 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 | |
| isCurrent - | 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 TagResourceContract or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :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.TagResourceCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("TagResourceCollection", 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/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py deleted file mode 100644 index 9d526e9f9205..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py +++ /dev/null @@ -1,172 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._tenant_access_git_operations import ( - build_regenerate_primary_key_request, - build_regenerate_secondary_key_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TenantAccessGitOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`tenant_access_git` 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 regenerate_primary_key( - self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> None: - """Regenerate primary access key for GIT. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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 [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( - self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> None: - """Regenerate secondary access key for GIT. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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 [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/_tenant_access_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py deleted file mode 100644 index d24cf8f944c2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py +++ /dev/null @@ -1,785 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._tenant_access_operations import ( - build_create_request, - build_get_entity_tag_request, - build_get_request, - build_list_by_service_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TenantAccessOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`tenant_access` 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, **kwargs: Any - ) -> AsyncIterable["_models.AccessInformationContract"]: - """Returns list of access infos - for Git and Management endpoints. - - :param resource_group_name: The name of the resource group. The name is 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: Not used. Default value is None. - :type filter: str - :return: An iterator like instance of either AccessInformationContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AccessInformationContract] - :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.AccessInformationCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("AccessInformationCollection", 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, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> bool: - """Tenant access metadata. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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) - - 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, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> _models.AccessInformationContract: - """Get tenant access information details without secrets. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AccessInformationContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - access_name=access_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AccessInformationContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def create( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: _models.AccessInformationCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. 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: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: Union[_models.AccessInformationCreateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. Is either a - AccessInformationCreateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters or - IO[bytes] - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AccessInformationContract] = 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, "AccessInformationCreateParameters") - - _request = build_create_request( - resource_group_name=resource_group_name, - service_name=service_name, - access_name=access_name, - 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("AccessInformationContract", 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, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: _models.AccessInformationUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. 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: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: Union[_models.AccessInformationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. Is either a - AccessInformationUpdateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters or - IO[bytes] - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AccessInformationContract] = 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, "AccessInformationUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - access_name=access_name, - 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("AccessInformationContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def regenerate_primary_key( - self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> None: - """Regenerate primary access key. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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 [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( - self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> None: - """Regenerate secondary access key. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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 [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, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> _models.AccessInformationSecretsContract: - """Get tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: AccessInformationSecretsContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AccessInformationSecretsContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_request( - resource_group_name=resource_group_name, - service_name=service_name, - access_name=access_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AccessInformationSecretsContract", 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/_tenant_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py deleted file mode 100644 index 2d31e057a4b3..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py +++ /dev/null @@ -1,814 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -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._tenant_configuration_operations import ( - build_deploy_request, - build_get_sync_state_request, - build_save_request, - build_validate_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TenantConfigurationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`tenant_configuration` 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 _deploy_initial( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, "DeployConfigurationParameters") - - _request = build_deploy_request( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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_deploy( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: _models.DeployConfigurationParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationResultContract]: - """This operation applies changes from the specified Git branch to the configuration database. - This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-deploy-any-service-configuration-changes-to-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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Deploy Configuration parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters - :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 OperationResultContract or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_deploy( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationResultContract]: - """This operation applies changes from the specified Git branch to the configuration database. - This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-deploy-any-service-configuration-changes-to-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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Deploy Configuration 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 OperationResultContract or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_deploy( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationResultContract]: - """This operation applies changes from the specified Git branch to the configuration database. - This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-deploy-any-service-configuration-changes-to-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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Deploy Configuration parameters. Is either a DeployConfigurationParameters - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or IO[bytes] - :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 = case_insensitive_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.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._deploy_initial( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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("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 - ) - - async def _save_initial( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.SaveConfigurationParameter, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, "SaveConfigurationParameter") - - _request = build_save_request( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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_save( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: _models.SaveConfigurationParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationResultContract]: - """This operation creates a commit with the current configuration snapshot to the specified branch - in the repository. This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-save-the-service-configuration-to-the-git-repository - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Save Configuration parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter - :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 OperationResultContract or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_save( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationResultContract]: - """This operation creates a commit with the current configuration snapshot to the specified branch - in the repository. This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-save-the-service-configuration-to-the-git-repository - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Save Configuration 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 OperationResultContract or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_save( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.SaveConfigurationParameter, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationResultContract]: - """This operation creates a commit with the current configuration snapshot to the specified branch - in the repository. This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-save-the-service-configuration-to-the-git-repository - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Save Configuration parameters. Is either a SaveConfigurationParameter type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter or IO[bytes] - :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 = case_insensitive_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.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._save_initial( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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("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 - ) - - async def _validate_initial( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, "DeployConfigurationParameters") - - _request = build_validate_request( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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_validate( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: _models.DeployConfigurationParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationResultContract]: - """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Validate Configuration parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters - :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 OperationResultContract or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_validate( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationResultContract]: - """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Validate Configuration 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 OperationResultContract or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_validate( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.OperationResultContract]: - """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Validate Configuration parameters. Is either a DeployConfigurationParameters - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or IO[bytes] - :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 = case_insensitive_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.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._validate_initial( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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("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 - ) - - @distributed_trace_async - async def get_sync_state( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - **kwargs: Any - ) -> _models.TenantConfigurationSyncStateContract: - """Gets the status of the most recent synchronization between the configuration database and the - Git repository. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :return: TenantConfigurationSyncStateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.TenantConfigurationSyncStateContract] = kwargs.pop("cls", None) - - _request = build_get_sync_state_request( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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("TenantConfigurationSyncStateContract", 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/_tenant_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py deleted file mode 100644 index 3c1b2172ba33..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_settings_operations.py +++ /dev/null @@ -1,213 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._tenant_settings_operations import 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TenantSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`tenant_settings` 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, **kwargs: Any - ) -> AsyncIterable["_models.TenantSettingsContract"]: - """Public settings. - - :param resource_group_name: The name of the resource group. The name is 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: Not used. Default value is None. - :type filter: str - :return: An iterator like instance of either TenantSettingsContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsContract] - :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.TenantSettingsCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("TenantSettingsCollection", 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, - settings_type: Union[str, _models.SettingsTypeName], - **kwargs: Any - ) -> _models.TenantSettingsContract: - """Get tenant settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param settings_type: The identifier of the settings. "public" Required. - :type settings_type: str or ~azure.mgmt.apimanagement.models.SettingsTypeName - :return: TenantSettingsContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.TenantSettingsContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - settings_type=settings_type, - 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("TenantSettingsContract", 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/_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py deleted file mode 100644 index 9de0b5d32208..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py +++ /dev/null @@ -1,121 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._user_confirmation_password_operations import build_send_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class UserConfirmationPasswordOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`user_confirmation_password` 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 send( - self, - resource_group_name: str, - service_name: str, - user_id: str, - app_type: Optional[Union[str, _models.AppType]] = None, - **kwargs: Any - ) -> None: - """Sends confirmation. - - :param resource_group_name: The name of the resource group. The name is 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 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: MutableMapping = { - 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_send_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_id, - subscription_id=self._config.subscription_id, - app_type=app_type, - 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 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 deleted file mode 100644 index 10cf896115aa..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py +++ /dev/null @@ -1,165 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._user_group_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class UserGroupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`user_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( - self, - resource_group_name: str, - service_name: str, - user_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.GroupContract"]: - """Lists all user 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 user_id: User identifier. Must be unique in the current API Management service instance. - Required. - :type user_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 |
. 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 = { - 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, - user_id=user_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) 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 deleted file mode 100644 index 0ca5c2dbda7f..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py +++ /dev/null @@ -1,145 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._user_identities_operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class UserIdentitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`user_identities` 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, user_id: str, **kwargs: Any - ) -> AsyncIterable["_models.UserIdentityContract"]: - """List of all user identities. - - :param resource_group_name: The name of the resource group. The name is 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 - :return: An iterator like instance of either UserIdentityContract or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserIdentityContract] - :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.UserIdentityCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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) - - 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("UserIdentityCollection", 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/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py deleted file mode 100644 index b2927b9970e1..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py +++ /dev/null @@ -1,999 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._user_operations import ( - build_create_or_update_request, - build_delete_request, - build_generate_sso_url_request, - build_get_entity_tag_request, - build_get_request, - build_get_shared_access_token_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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class UserOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`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_by_service( - self, - resource_group_name: str, - service_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - expand_groups: Optional[bool] = None, - **kwargs: Any - ) -> AsyncIterable["_models.UserContract"]: - """Lists a collection of registered users in the specified 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 |
|-------------|-------------|-------------|-------------|
| 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 - |
| state | filter | eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | - |
| note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| 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: Detailed Group in response. Default value is None. - :type expand_groups: bool - :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 = { - 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, - expand_groups=expand_groups, - 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 get_entity_tag(self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the user 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 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 = { - 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, - 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]: - map_error(status_code=response.status_code, 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, user_id: str, **kwargs: Any - ) -> _models.UserContract: - """Gets the details of the user 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 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 = { - 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_get_request( - resource_group_name=resource_group_name, - service_name=service_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]: - map_error(status_code=response.status_code, 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("UserContract", 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, - user_id: str, - parameters: _models.UserCreateParameters, - notify: Optional[bool] = None, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserContract: - """Creates or Updates a 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 parameters: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters - :param notify: Send an Email notification to the User. 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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: IO[bytes], - notify: Optional[bool] = None, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserContract: - """Creates or Updates a 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 parameters: Create or update parameters. Required. - :type parameters: IO[bytes] - :param notify: Send an Email notification to the User. 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 - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: Union[_models.UserCreateParameters, IO[bytes]], - notify: Optional[bool] = None, - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.UserContract: - """Creates or Updates a 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 parameters: Create or update parameters. Is either a UserCreateParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters or IO[bytes] - :param notify: Send an Email notification to the User. 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 - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.UserContract] = 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, "UserCreateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_id, - subscription_id=self._config.subscription_id, - notify=notify, - 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("UserContract", 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, - user_id: str, - if_match: str, - parameters: _models.UserUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserContract: - """Updates the details of the user 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 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 parameters: Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - service_name: str, - user_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserContract: - """Updates the details of the user 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 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 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: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - service_name: str, - user_id: str, - if_match: str, - parameters: Union[_models.UserUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.UserContract: - """Updates the details of the user 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 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 parameters: Update parameters. Is either a UserUpdateParameters type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters or IO[bytes] - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.UserContract] = 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, "UserUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_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("UserContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - async def _delete_initial( - 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 - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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, - service_name=service_name, - user_id=user_id, - subscription_id=self._config.subscription_id, - if_match=if_match, - delete_subscriptions=delete_subscriptions, - notify=notify, - app_type=app_type, - 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")) - 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_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( - self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any - ) -> _models.GenerateSsoUrlResult: - """Retrieves a redirection URL containing an authentication token for signing a given user into - the developer portal. - - :param resource_group_name: The name of the resource group. The name is 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 - :return: GenerateSsoUrlResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GenerateSsoUrlResult] = kwargs.pop("cls", None) - - _request = build_generate_sso_url_request( - resource_group_name=resource_group_name, - service_name=service_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]: - map_error(status_code=response.status_code, 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("GenerateSsoUrlResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def get_shared_access_token( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: _models.UserTokenParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserTokenResult: - """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: UserTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def get_shared_access_token( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserTokenResult: - """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token 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: UserTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def get_shared_access_token( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: Union[_models.UserTokenParameters, IO[bytes]], - **kwargs: Any - ) -> _models.UserTokenResult: - """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Is either a UserTokenParameters type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters or IO[bytes] - :return: UserTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.UserTokenResult] = 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, "UserTokenParameters") - - _request = build_get_shared_access_token_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_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("UserTokenResult", 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/_user_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py deleted file mode 100644 index 89a33003da46..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py +++ /dev/null @@ -1,240 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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._user_subscription_operations import build_get_request, build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class UserSubscriptionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.aio.ApiManagementClient`'s - :attr:`user_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, - user_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SubscriptionContract"]: - """Lists the collection of subscriptions of the specified 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 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 |
. 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 = { - 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, - user_id=user_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( - self, resource_group_name: str, service_name: str, user_id: str, sid: str, **kwargs: Any - ) -> _models.SubscriptionContract: - """Gets the specified Subscription entity associated with a particular 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 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 = { - 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, - user_id=user_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 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 deleted file mode 100644 index 66a0a8fcd151..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_diagnostic_operations.py +++ /dev/null @@ -1,781 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index abf7f1ca2b8d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_export_operations.py +++ /dev/null @@ -1,135 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 deleted file mode 100644 index 4feb9293dcc2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_operations.py +++ /dev/null @@ -1,789 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 016834ac3744..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operation_policy_operations.py +++ /dev/null @@ -1,611 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index c69bd4f4a5f5..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_operations.py +++ /dev/null @@ -1,833 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 4c22485d489b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_policy_operations.py +++ /dev/null @@ -1,573 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 150703859497..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_release_operations.py +++ /dev/null @@ -1,783 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index e77deaadf15d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_revision_operations.py +++ /dev/null @@ -1,168 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 deleted file mode 100644 index f5fa24fd5cec..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_schema_operations.py +++ /dev/null @@ -1,675 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index c0099fc6f9c6..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_api_version_set_operations.py +++ /dev/null @@ -1,725 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index a993ef4e31d7..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_backend_operations.py +++ /dev/null @@ -1,727 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 1c935d911156..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_certificate_operations.py +++ /dev/null @@ -1,645 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 = { - 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 deleted file mode 100644 index 53cec2414680..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_diagnostic_operations.py +++ /dev/null @@ -1,725 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index ce644caac83e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_global_schema_operations.py +++ /dev/null @@ -1,644 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 9ab7df544de9..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_operations.py +++ /dev/null @@ -1,729 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index c13ddfc5e3ab..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_group_user_operations.py +++ /dev/null @@ -1,380 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 8005c83f6ac9..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_logger_operations.py +++ /dev/null @@ -1,730 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 5fc96e18e53a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_named_value_operations.py +++ /dev/null @@ -1,1099 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index cf753870d22d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_operations.py +++ /dev/null @@ -1,313 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 2c98bad34835..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_email_operations.py +++ /dev/null @@ -1,355 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index c68a1729b1df..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_notification_recipient_user_operations.py +++ /dev/null @@ -1,358 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 8ead8275f43e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_operations.py +++ /dev/null @@ -1,677 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 97ef12f628a7..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_fragment_operations.py +++ /dev/null @@ -1,724 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 = { - 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 deleted file mode 100644 index 7966b954e973..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_policy_operations.py +++ /dev/null @@ -1,541 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 45f523999da0..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_api_link_operations.py +++ /dev/null @@ -1,497 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 65c2a9dc4fad..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_group_link_operations.py +++ /dev/null @@ -1,497 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 5f53e4d56424..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_operations.py +++ /dev/null @@ -1,743 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index ada97a7bd514..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_product_policy_operations.py +++ /dev/null @@ -1,543 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 176b18d15cd6..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_subscription_operations.py +++ /dev/null @@ -1,1003 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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( - 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 = { - 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( - 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 = { - 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 = { - 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 deleted file mode 100644 index 8964a9711aa2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_api_link_operations.py +++ /dev/null @@ -1,496 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 92344df577dd..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operation_link_operations.py +++ /dev/null @@ -1,497 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 0b8536c46049..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_operations.py +++ /dev/null @@ -1,723 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 deleted file mode 100644 index 201f264de6aa..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_workspace_tag_product_link_operations.py +++ /dev/null @@ -1,497 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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 = { - 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 = { - 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 = { - 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( - 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 = { - 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 6e14ab4fbf4c..9336748f9988 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 @@ -1,8 +1,9 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,16 +14,17 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore - AccessInformationCollection, +from ._models import ( # type: ignore AccessInformationContract, + AccessInformationContractProperties, + AccessInformationCreateParameterProperties, AccessInformationCreateParameters, AccessInformationSecretsContract, + AccessInformationUpdateParameterProperties, AccessInformationUpdateParameters, AdditionalLocation, - AllPoliciesCollection, AllPoliciesContract, - ApiCollection, + AllPoliciesContractProperties, ApiContactInformation, ApiContract, ApiContractProperties, @@ -35,9 +37,7 @@ ApiExportResultValue, ApiLicenseInformation, ApiManagementGatewayBaseProperties, - ApiManagementGatewayConfigConnectionListResult, ApiManagementGatewayConfigConnectionResource, - ApiManagementGatewayListResult, ApiManagementGatewayProperties, ApiManagementGatewayResource, ApiManagementGatewaySkuProperties, @@ -51,7 +51,6 @@ ApiManagementServiceGetDomainOwnershipIdentifierResult, ApiManagementServiceGetSsoTokenResult, ApiManagementServiceIdentity, - ApiManagementServiceListResult, ApiManagementServiceNameAvailabilityResult, ApiManagementServiceProperties, ApiManagementServiceResource, @@ -66,19 +65,14 @@ ApiManagementSkuRestrictionInfo, ApiManagementSkuRestrictions, ApiManagementSkuZoneDetails, - ApiManagementSkusResult, - ApiManagementWorkspaceLinksListResult, ApiManagementWorkspaceLinksProperties, ApiManagementWorkspaceLinksResource, - ApiReleaseCollection, ApiReleaseContract, - ApiRevisionCollection, + ApiReleaseContractProperties, ApiRevisionContract, - ApiRevisionInfoContract, ApiTagResourceContractProperties, ApiUpdateContract, ApiVersionConstraint, - ApiVersionSetCollection, ApiVersionSetContract, ApiVersionSetContractDetails, ApiVersionSetContractProperties, @@ -88,20 +82,22 @@ ApimResource, ArmIdWrapper, AssociationContract, + AssociationContractProperties, AuthenticationSettingsContract, - AuthorizationAccessPolicyCollection, AuthorizationAccessPolicyContract, - AuthorizationCollection, + AuthorizationAccessPolicyContractProperties, AuthorizationConfirmConsentCodeRequestContract, AuthorizationContract, + AuthorizationContractProperties, AuthorizationError, AuthorizationLoginRequestContract, AuthorizationLoginResponseContract, - AuthorizationProviderCollection, AuthorizationProviderContract, + AuthorizationProviderContractProperties, + AuthorizationProviderKeyVaultContract, + AuthorizationProviderKeyVaultCreateProperties, AuthorizationProviderOAuth2GrantTypes, AuthorizationProviderOAuth2Settings, - AuthorizationServerCollection, AuthorizationServerContract, AuthorizationServerContractBaseProperties, AuthorizationServerContractProperties, @@ -112,32 +108,43 @@ BackendBaseParameters, BackendBaseParametersPool, BackendCircuitBreaker, - BackendCollection, BackendConfiguration, BackendContract, BackendContractProperties, BackendCredentialsContract, + BackendFailureResponse, BackendPool, BackendPoolItem, BackendProperties, BackendProxyContract, BackendReconnectContract, + BackendReconnectProperties, BackendServiceFabricClusterProperties, + BackendSessionAffinity, + BackendSessionId, BackendSubnetConfiguration, BackendTlsProperties, BackendUpdateParameterProperties, BackendUpdateParameters, BodyDiagnosticSettings, - CacheCollection, CacheContract, + CacheContractProperties, CacheUpdateParameters, - CertificateCollection, + CacheUpdateProperties, CertificateConfiguration, CertificateContract, + CertificateContractProperties, CertificateCreateOrUpdateParameters, + CertificateCreateOrUpdateProperties, CertificateInformation, CircuitBreakerFailureCondition, CircuitBreakerRule, + ClientApplicationContract, + ClientApplicationContractProperties, + ClientApplicationProductLinkContract, + ClientApplicationProductLinkContractProperties, + ClientApplicationSecretsContract, + ClientApplicationSecretsContractEntra, ClientSecretContract, ConfigurationApi, ConnectivityCheckRequest, @@ -149,24 +156,26 @@ ConnectivityHop, ConnectivityIssue, ConnectivityStatusContract, - ContentItemCollection, ContentItemContract, - ContentTypeCollection, ContentTypeContract, + ContentTypeContractProperties, DataMasking, DataMaskingEntity, DeletedServiceContract, - DeletedServicesCollection, + DeletedServiceContractProperties, + DeployConfigurationParameterProperties, DeployConfigurationParameters, - DiagnosticCollection, DiagnosticContract, + DiagnosticContractProperties, + DiagnosticContractUpdateProperties, DiagnosticUpdateContract, - DocumentationCollection, DocumentationContract, + DocumentationContractProperties, DocumentationUpdateContract, - EmailTemplateCollection, EmailTemplateContract, + EmailTemplateContractProperties, EmailTemplateParametersContractProperties, + EmailTemplateUpdateParameterProperties, EmailTemplateUpdateParameters, EndpointDependency, EndpointDetail, @@ -177,32 +186,38 @@ ErrorResponseBody, FailureStatusCodeRange, FrontendConfiguration, - GatewayCertificateAuthorityCollection, GatewayCertificateAuthorityContract, - GatewayCollection, + GatewayCertificateAuthorityContractProperties, + GatewayConfigConnectionBaseProperties, GatewayConfigurationApi, GatewayContract, + GatewayContractProperties, GatewayDebugCredentialsContract, - GatewayHostnameConfigurationCollection, + GatewayHostnameBindingBaseProperties, + GatewayHostnameBindingCertificate, + GatewayHostnameBindingKeyVault, + GatewayHostnameBindingKeyVaultLastStatus, + GatewayHostnameBindingResource, GatewayHostnameConfigurationContract, + GatewayHostnameConfigurationContractProperties, GatewayKeyRegenerationRequestContract, GatewayKeysContract, GatewayListDebugCredentialsContract, GatewayListTraceContract, GatewayResourceSkuResult, - GatewayResourceSkuResults, GatewaySku, GatewaySkuCapacity, GatewayTokenContract, GatewayTokenRequestContract, GenerateSsoUrlResult, - GlobalSchemaCollection, GlobalSchemaContract, - GroupCollection, + GlobalSchemaContractProperties, GroupContract, GroupContractProperties, GroupCreateParameters, + GroupCreateParametersProperties, GroupUpdateParameters, + GroupUpdateParametersProperties, HTTPHeader, HostnameConfiguration, HttpMessageDiagnostic, @@ -211,14 +226,12 @@ IdentityProviderContractProperties, IdentityProviderCreateContract, IdentityProviderCreateContractProperties, - IdentityProviderList, IdentityProviderUpdateParameters, IdentityProviderUpdateProperties, - IssueAttachmentCollection, IssueAttachmentContract, - IssueCollection, - IssueCommentCollection, + IssueAttachmentContractProperties, IssueCommentContract, + IssueCommentContractProperties, IssueContract, IssueContractBaseProperties, IssueContractProperties, @@ -227,11 +240,14 @@ KeyVaultContractCreateProperties, KeyVaultContractProperties, KeyVaultLastAccessStatusContractProperties, - LoggerCollection, + LLMDiagnosticSettings, + LLMMessageDiagnosticSettings, LoggerContract, + LoggerContractProperties, LoggerUpdateContract, + LoggerUpdateParameters, + ManagedServiceIdentity, MigrateToStv2Contract, - NamedValueCollection, NamedValueContract, NamedValueContractProperties, NamedValueCreateContract, @@ -242,21 +258,21 @@ NamedValueUpdateParameters, NetworkStatusContract, NetworkStatusContractByLocation, - NotificationCollection, NotificationContract, + NotificationContractProperties, OAuth2AuthenticationSettingsContract, OpenIdAuthenticationSettingsContract, - OpenIdConnectProviderCollection, OpenidConnectProviderContract, + OpenidConnectProviderContractProperties, OpenidConnectProviderUpdateContract, + OpenidConnectProviderUpdateContractProperties, Operation, - OperationCollection, OperationContract, OperationContractProperties, OperationDisplay, OperationEntityBaseContract, - OperationListResult, OperationResultContract, + OperationResultContractProperties, OperationResultLogItemContract, OperationStatusResult, OperationTagResourceContractProperties, @@ -269,76 +285,81 @@ PipelineDiagnosticSettings, PolicyCollection, PolicyContract, + PolicyContractProperties, PolicyDescriptionCollection, PolicyDescriptionContract, - PolicyFragmentCollection, + PolicyDescriptionContractProperties, PolicyFragmentContract, - PolicyRestrictionCollection, + PolicyFragmentContractProperties, PolicyRestrictionContract, + PolicyRestrictionContractProperties, PolicyRestrictionUpdateContract, - PolicyWithComplianceCollection, - PolicyWithComplianceContract, - PortalConfigCollection, PortalConfigContract, PortalConfigCorsProperties, PortalConfigCspProperties, PortalConfigDelegationProperties, + PortalConfigProperties, PortalConfigPropertiesSignin, PortalConfigPropertiesSignup, PortalConfigTermsOfServiceProperties, PortalDelegationSettings, - PortalRevisionCollection, + PortalDelegationSettingsProperties, PortalRevisionContract, + PortalRevisionContractProperties, PortalSettingValidationKeyContract, PortalSettingsCollection, PortalSettingsContract, + PortalSettingsContractProperties, + PortalSigninSettingProperties, PortalSigninSettings, PortalSignupSettings, + PortalSignupSettingsProperties, PrivateEndpoint, PrivateEndpointConnection, - PrivateEndpointConnectionListResult, + PrivateEndpointConnectionProperties, PrivateEndpointConnectionRequest, PrivateEndpointConnectionRequestProperties, + PrivateEndpointConnectionWrapperProperties, PrivateLinkResource, PrivateLinkResourceListResult, + PrivateLinkResourceProperties, PrivateLinkServiceConnectionState, - ProductApiLinkCollection, ProductApiLinkContract, - ProductCollection, + ProductApiLinkContractProperties, + ProductApplicationContract, + ProductApplicationContractEntra, ProductContract, ProductContractProperties, ProductEntityBaseParameters, - ProductGroupLinkCollection, + ProductEntityBaseParametersApplication, ProductGroupLinkContract, + ProductGroupLinkContractProperties, ProductTagResourceContractProperties, ProductUpdateParameters, ProductUpdateProperties, ProxyResource, QuotaCounterCollection, QuotaCounterContract, - QuotaCounterValueContract, QuotaCounterValueContractProperties, QuotaCounterValueUpdateContract, RecipientEmailCollection, RecipientEmailContract, + RecipientEmailContractProperties, RecipientUserCollection, RecipientUserContract, + RecipientUsersContractProperties, RecipientsContractProperties, RegionContract, - RegionListResult, RegistrationDelegationSettingsProperties, RemotePrivateEndpointConnectionWrapper, - ReportCollection, ReportRecordContract, RepresentationContract, RequestContract, - RequestReportCollection, RequestReportRecordContract, - ResolverCollection, ResolverContract, - ResolverResultContract, - ResolverResultLogItemContract, + ResolverEntityBaseContract, ResolverUpdateContract, + ResolverUpdateContractProperties, Resource, ResourceCollection, ResourceCollectionValueItem, @@ -346,68 +367,73 @@ ResourceSku, ResourceSkuCapacity, ResourceSkuResult, - ResourceSkuResults, ResponseContract, SamplingSettings, SaveConfigurationParameter, - SchemaCollection, + SaveConfigurationParameterProperties, SchemaContract, - SubscriptionCollection, + SchemaContractProperties, + SchemaDocumentProperties, SubscriptionContract, + SubscriptionContractProperties, + SubscriptionCreateParameterProperties, SubscriptionCreateParameters, SubscriptionKeyParameterNamesContract, SubscriptionKeysContract, + SubscriptionUpdateParameterProperties, SubscriptionUpdateParameters, SubscriptionsDelegationSettingsProperties, SystemData, - TagApiLinkCollection, TagApiLinkContract, - TagCollection, + TagApiLinkContractProperties, TagContract, + TagContractProperties, TagCreateUpdateParameters, TagDescriptionBaseProperties, - TagDescriptionCollection, TagDescriptionContract, TagDescriptionContractProperties, TagDescriptionCreateParameters, - TagOperationLinkCollection, TagOperationLinkContract, - TagProductLinkCollection, + TagOperationLinkContractProperties, TagProductLinkContract, - TagResourceCollection, + TagProductLinkContractProperties, TagResourceContract, TagResourceContractProperties, TenantConfigurationSyncStateContract, - TenantSettingsCollection, + TenantConfigurationSyncStateContractProperties, TenantSettingsContract, + TenantSettingsContractProperties, TermsOfServiceProperties, TokenBodyParameterContract, - UserCollection, + ToolContract, + ToolContractProperties, + TrackedResource, + UserAssignedIdentity, UserContract, UserContractProperties, UserCreateParameterProperties, UserCreateParameters, UserEntityBaseParameters, - UserIdentityCollection, UserIdentityContract, UserIdentityProperties, + UserTokenParameterProperties, UserTokenParameters, UserTokenResult, UserUpdateParameters, UserUpdateParametersProperties, VirtualNetworkConfiguration, - WikiCollection, WikiContract, + WikiContractProperties, WikiDocumentationContract, WikiUpdateContract, - WorkspaceCollection, WorkspaceContract, + WorkspaceContractProperties, WorkspaceLinksBaseProperties, WorkspaceLinksGateway, X509CertificateName, ) -from ._api_management_client_enums import ( # type: ignore +from ._enums import ( # type: ignore AccessIdName, AccessType, AlwaysLog, @@ -419,16 +445,18 @@ ApimIdentityType, AppType, AsyncOperationStatus, - AsyncResolverStatus, AuthorizationMethod, AuthorizationType, BackendProtocol, + BackendSessionIdSource, BackendType, BearerTokenSendingMethod, BearerTokenSendingMethods, + CarbonEmissionCategory, CertificateConfigurationStoreName, CertificateSource, CertificateStatus, + ClientApplicationState, ClientAuthenticationMethod, ConfigurationIdName, Confirmation, @@ -451,10 +479,14 @@ IdentityProviderType, IssueType, KeyType, + KeyVaultFetchCode, KeyVaultRefreshState, LegacyApiState, LegacyPortalStatus, + LlmDiagnosticSettings, + LlmMessageLogTypes, LoggerType, + ManagedServiceIdentityType, Method, MigrateToStv2Mode, NameAvailabilityReason, @@ -476,9 +508,11 @@ PreferredIPVersion, PrivateEndpointConnectionProvisioningState, PrivateEndpointServiceConnectionStatus, + ProductAuthType, ProductState, Protocol, PublicNetworkAccess, + ReleaseChannel, ResourceSkuCapacityScaleType, SamplingType, SchemaType, @@ -500,15 +534,16 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "AccessInformationCollection", "AccessInformationContract", + "AccessInformationContractProperties", + "AccessInformationCreateParameterProperties", "AccessInformationCreateParameters", "AccessInformationSecretsContract", + "AccessInformationUpdateParameterProperties", "AccessInformationUpdateParameters", "AdditionalLocation", - "AllPoliciesCollection", "AllPoliciesContract", - "ApiCollection", + "AllPoliciesContractProperties", "ApiContactInformation", "ApiContract", "ApiContractProperties", @@ -521,9 +556,7 @@ "ApiExportResultValue", "ApiLicenseInformation", "ApiManagementGatewayBaseProperties", - "ApiManagementGatewayConfigConnectionListResult", "ApiManagementGatewayConfigConnectionResource", - "ApiManagementGatewayListResult", "ApiManagementGatewayProperties", "ApiManagementGatewayResource", "ApiManagementGatewaySkuProperties", @@ -537,7 +570,6 @@ "ApiManagementServiceGetDomainOwnershipIdentifierResult", "ApiManagementServiceGetSsoTokenResult", "ApiManagementServiceIdentity", - "ApiManagementServiceListResult", "ApiManagementServiceNameAvailabilityResult", "ApiManagementServiceProperties", "ApiManagementServiceResource", @@ -552,19 +584,14 @@ "ApiManagementSkuRestrictionInfo", "ApiManagementSkuRestrictions", "ApiManagementSkuZoneDetails", - "ApiManagementSkusResult", - "ApiManagementWorkspaceLinksListResult", "ApiManagementWorkspaceLinksProperties", "ApiManagementWorkspaceLinksResource", - "ApiReleaseCollection", "ApiReleaseContract", - "ApiRevisionCollection", + "ApiReleaseContractProperties", "ApiRevisionContract", - "ApiRevisionInfoContract", "ApiTagResourceContractProperties", "ApiUpdateContract", "ApiVersionConstraint", - "ApiVersionSetCollection", "ApiVersionSetContract", "ApiVersionSetContractDetails", "ApiVersionSetContractProperties", @@ -574,20 +601,22 @@ "ApimResource", "ArmIdWrapper", "AssociationContract", + "AssociationContractProperties", "AuthenticationSettingsContract", - "AuthorizationAccessPolicyCollection", "AuthorizationAccessPolicyContract", - "AuthorizationCollection", + "AuthorizationAccessPolicyContractProperties", "AuthorizationConfirmConsentCodeRequestContract", "AuthorizationContract", + "AuthorizationContractProperties", "AuthorizationError", "AuthorizationLoginRequestContract", "AuthorizationLoginResponseContract", - "AuthorizationProviderCollection", "AuthorizationProviderContract", + "AuthorizationProviderContractProperties", + "AuthorizationProviderKeyVaultContract", + "AuthorizationProviderKeyVaultCreateProperties", "AuthorizationProviderOAuth2GrantTypes", "AuthorizationProviderOAuth2Settings", - "AuthorizationServerCollection", "AuthorizationServerContract", "AuthorizationServerContractBaseProperties", "AuthorizationServerContractProperties", @@ -598,32 +627,43 @@ "BackendBaseParameters", "BackendBaseParametersPool", "BackendCircuitBreaker", - "BackendCollection", "BackendConfiguration", "BackendContract", "BackendContractProperties", "BackendCredentialsContract", + "BackendFailureResponse", "BackendPool", "BackendPoolItem", "BackendProperties", "BackendProxyContract", "BackendReconnectContract", + "BackendReconnectProperties", "BackendServiceFabricClusterProperties", + "BackendSessionAffinity", + "BackendSessionId", "BackendSubnetConfiguration", "BackendTlsProperties", "BackendUpdateParameterProperties", "BackendUpdateParameters", "BodyDiagnosticSettings", - "CacheCollection", "CacheContract", + "CacheContractProperties", "CacheUpdateParameters", - "CertificateCollection", + "CacheUpdateProperties", "CertificateConfiguration", "CertificateContract", + "CertificateContractProperties", "CertificateCreateOrUpdateParameters", + "CertificateCreateOrUpdateProperties", "CertificateInformation", "CircuitBreakerFailureCondition", "CircuitBreakerRule", + "ClientApplicationContract", + "ClientApplicationContractProperties", + "ClientApplicationProductLinkContract", + "ClientApplicationProductLinkContractProperties", + "ClientApplicationSecretsContract", + "ClientApplicationSecretsContractEntra", "ClientSecretContract", "ConfigurationApi", "ConnectivityCheckRequest", @@ -635,24 +675,26 @@ "ConnectivityHop", "ConnectivityIssue", "ConnectivityStatusContract", - "ContentItemCollection", "ContentItemContract", - "ContentTypeCollection", "ContentTypeContract", + "ContentTypeContractProperties", "DataMasking", "DataMaskingEntity", "DeletedServiceContract", - "DeletedServicesCollection", + "DeletedServiceContractProperties", + "DeployConfigurationParameterProperties", "DeployConfigurationParameters", - "DiagnosticCollection", "DiagnosticContract", + "DiagnosticContractProperties", + "DiagnosticContractUpdateProperties", "DiagnosticUpdateContract", - "DocumentationCollection", "DocumentationContract", + "DocumentationContractProperties", "DocumentationUpdateContract", - "EmailTemplateCollection", "EmailTemplateContract", + "EmailTemplateContractProperties", "EmailTemplateParametersContractProperties", + "EmailTemplateUpdateParameterProperties", "EmailTemplateUpdateParameters", "EndpointDependency", "EndpointDetail", @@ -663,32 +705,38 @@ "ErrorResponseBody", "FailureStatusCodeRange", "FrontendConfiguration", - "GatewayCertificateAuthorityCollection", "GatewayCertificateAuthorityContract", - "GatewayCollection", + "GatewayCertificateAuthorityContractProperties", + "GatewayConfigConnectionBaseProperties", "GatewayConfigurationApi", "GatewayContract", + "GatewayContractProperties", "GatewayDebugCredentialsContract", - "GatewayHostnameConfigurationCollection", + "GatewayHostnameBindingBaseProperties", + "GatewayHostnameBindingCertificate", + "GatewayHostnameBindingKeyVault", + "GatewayHostnameBindingKeyVaultLastStatus", + "GatewayHostnameBindingResource", "GatewayHostnameConfigurationContract", + "GatewayHostnameConfigurationContractProperties", "GatewayKeyRegenerationRequestContract", "GatewayKeysContract", "GatewayListDebugCredentialsContract", "GatewayListTraceContract", "GatewayResourceSkuResult", - "GatewayResourceSkuResults", "GatewaySku", "GatewaySkuCapacity", "GatewayTokenContract", "GatewayTokenRequestContract", "GenerateSsoUrlResult", - "GlobalSchemaCollection", "GlobalSchemaContract", - "GroupCollection", + "GlobalSchemaContractProperties", "GroupContract", "GroupContractProperties", "GroupCreateParameters", + "GroupCreateParametersProperties", "GroupUpdateParameters", + "GroupUpdateParametersProperties", "HTTPHeader", "HostnameConfiguration", "HttpMessageDiagnostic", @@ -697,14 +745,12 @@ "IdentityProviderContractProperties", "IdentityProviderCreateContract", "IdentityProviderCreateContractProperties", - "IdentityProviderList", "IdentityProviderUpdateParameters", "IdentityProviderUpdateProperties", - "IssueAttachmentCollection", "IssueAttachmentContract", - "IssueCollection", - "IssueCommentCollection", + "IssueAttachmentContractProperties", "IssueCommentContract", + "IssueCommentContractProperties", "IssueContract", "IssueContractBaseProperties", "IssueContractProperties", @@ -713,11 +759,14 @@ "KeyVaultContractCreateProperties", "KeyVaultContractProperties", "KeyVaultLastAccessStatusContractProperties", - "LoggerCollection", + "LLMDiagnosticSettings", + "LLMMessageDiagnosticSettings", "LoggerContract", + "LoggerContractProperties", "LoggerUpdateContract", + "LoggerUpdateParameters", + "ManagedServiceIdentity", "MigrateToStv2Contract", - "NamedValueCollection", "NamedValueContract", "NamedValueContractProperties", "NamedValueCreateContract", @@ -728,21 +777,21 @@ "NamedValueUpdateParameters", "NetworkStatusContract", "NetworkStatusContractByLocation", - "NotificationCollection", "NotificationContract", + "NotificationContractProperties", "OAuth2AuthenticationSettingsContract", "OpenIdAuthenticationSettingsContract", - "OpenIdConnectProviderCollection", "OpenidConnectProviderContract", + "OpenidConnectProviderContractProperties", "OpenidConnectProviderUpdateContract", + "OpenidConnectProviderUpdateContractProperties", "Operation", - "OperationCollection", "OperationContract", "OperationContractProperties", "OperationDisplay", "OperationEntityBaseContract", - "OperationListResult", "OperationResultContract", + "OperationResultContractProperties", "OperationResultLogItemContract", "OperationStatusResult", "OperationTagResourceContractProperties", @@ -755,76 +804,81 @@ "PipelineDiagnosticSettings", "PolicyCollection", "PolicyContract", + "PolicyContractProperties", "PolicyDescriptionCollection", "PolicyDescriptionContract", - "PolicyFragmentCollection", + "PolicyDescriptionContractProperties", "PolicyFragmentContract", - "PolicyRestrictionCollection", + "PolicyFragmentContractProperties", "PolicyRestrictionContract", + "PolicyRestrictionContractProperties", "PolicyRestrictionUpdateContract", - "PolicyWithComplianceCollection", - "PolicyWithComplianceContract", - "PortalConfigCollection", "PortalConfigContract", "PortalConfigCorsProperties", "PortalConfigCspProperties", "PortalConfigDelegationProperties", + "PortalConfigProperties", "PortalConfigPropertiesSignin", "PortalConfigPropertiesSignup", "PortalConfigTermsOfServiceProperties", "PortalDelegationSettings", - "PortalRevisionCollection", + "PortalDelegationSettingsProperties", "PortalRevisionContract", + "PortalRevisionContractProperties", "PortalSettingValidationKeyContract", "PortalSettingsCollection", "PortalSettingsContract", + "PortalSettingsContractProperties", + "PortalSigninSettingProperties", "PortalSigninSettings", "PortalSignupSettings", + "PortalSignupSettingsProperties", "PrivateEndpoint", "PrivateEndpointConnection", - "PrivateEndpointConnectionListResult", + "PrivateEndpointConnectionProperties", "PrivateEndpointConnectionRequest", "PrivateEndpointConnectionRequestProperties", + "PrivateEndpointConnectionWrapperProperties", "PrivateLinkResource", "PrivateLinkResourceListResult", + "PrivateLinkResourceProperties", "PrivateLinkServiceConnectionState", - "ProductApiLinkCollection", "ProductApiLinkContract", - "ProductCollection", + "ProductApiLinkContractProperties", + "ProductApplicationContract", + "ProductApplicationContractEntra", "ProductContract", "ProductContractProperties", "ProductEntityBaseParameters", - "ProductGroupLinkCollection", + "ProductEntityBaseParametersApplication", "ProductGroupLinkContract", + "ProductGroupLinkContractProperties", "ProductTagResourceContractProperties", "ProductUpdateParameters", "ProductUpdateProperties", "ProxyResource", "QuotaCounterCollection", "QuotaCounterContract", - "QuotaCounterValueContract", "QuotaCounterValueContractProperties", "QuotaCounterValueUpdateContract", "RecipientEmailCollection", "RecipientEmailContract", + "RecipientEmailContractProperties", "RecipientUserCollection", "RecipientUserContract", + "RecipientUsersContractProperties", "RecipientsContractProperties", "RegionContract", - "RegionListResult", "RegistrationDelegationSettingsProperties", "RemotePrivateEndpointConnectionWrapper", - "ReportCollection", "ReportRecordContract", "RepresentationContract", "RequestContract", - "RequestReportCollection", "RequestReportRecordContract", - "ResolverCollection", "ResolverContract", - "ResolverResultContract", - "ResolverResultLogItemContract", + "ResolverEntityBaseContract", "ResolverUpdateContract", + "ResolverUpdateContractProperties", "Resource", "ResourceCollection", "ResourceCollectionValueItem", @@ -832,62 +886,67 @@ "ResourceSku", "ResourceSkuCapacity", "ResourceSkuResult", - "ResourceSkuResults", "ResponseContract", "SamplingSettings", "SaveConfigurationParameter", - "SchemaCollection", + "SaveConfigurationParameterProperties", "SchemaContract", - "SubscriptionCollection", + "SchemaContractProperties", + "SchemaDocumentProperties", "SubscriptionContract", + "SubscriptionContractProperties", + "SubscriptionCreateParameterProperties", "SubscriptionCreateParameters", "SubscriptionKeyParameterNamesContract", "SubscriptionKeysContract", + "SubscriptionUpdateParameterProperties", "SubscriptionUpdateParameters", "SubscriptionsDelegationSettingsProperties", "SystemData", - "TagApiLinkCollection", "TagApiLinkContract", - "TagCollection", + "TagApiLinkContractProperties", "TagContract", + "TagContractProperties", "TagCreateUpdateParameters", "TagDescriptionBaseProperties", - "TagDescriptionCollection", "TagDescriptionContract", "TagDescriptionContractProperties", "TagDescriptionCreateParameters", - "TagOperationLinkCollection", "TagOperationLinkContract", - "TagProductLinkCollection", + "TagOperationLinkContractProperties", "TagProductLinkContract", - "TagResourceCollection", + "TagProductLinkContractProperties", "TagResourceContract", "TagResourceContractProperties", "TenantConfigurationSyncStateContract", - "TenantSettingsCollection", + "TenantConfigurationSyncStateContractProperties", "TenantSettingsContract", + "TenantSettingsContractProperties", "TermsOfServiceProperties", "TokenBodyParameterContract", - "UserCollection", + "ToolContract", + "ToolContractProperties", + "TrackedResource", + "UserAssignedIdentity", "UserContract", "UserContractProperties", "UserCreateParameterProperties", "UserCreateParameters", "UserEntityBaseParameters", - "UserIdentityCollection", "UserIdentityContract", "UserIdentityProperties", + "UserTokenParameterProperties", "UserTokenParameters", "UserTokenResult", "UserUpdateParameters", "UserUpdateParametersProperties", "VirtualNetworkConfiguration", - "WikiCollection", "WikiContract", + "WikiContractProperties", "WikiDocumentationContract", "WikiUpdateContract", - "WorkspaceCollection", "WorkspaceContract", + "WorkspaceContractProperties", "WorkspaceLinksBaseProperties", "WorkspaceLinksGateway", "X509CertificateName", @@ -902,16 +961,18 @@ "ApimIdentityType", "AppType", "AsyncOperationStatus", - "AsyncResolverStatus", "AuthorizationMethod", "AuthorizationType", "BackendProtocol", + "BackendSessionIdSource", "BackendType", "BearerTokenSendingMethod", "BearerTokenSendingMethods", + "CarbonEmissionCategory", "CertificateConfigurationStoreName", "CertificateSource", "CertificateStatus", + "ClientApplicationState", "ClientAuthenticationMethod", "ConfigurationIdName", "Confirmation", @@ -934,10 +995,14 @@ "IdentityProviderType", "IssueType", "KeyType", + "KeyVaultFetchCode", "KeyVaultRefreshState", "LegacyApiState", "LegacyPortalStatus", + "LlmDiagnosticSettings", + "LlmMessageLogTypes", "LoggerType", + "ManagedServiceIdentityType", "Method", "MigrateToStv2Mode", "NameAvailabilityReason", @@ -959,9 +1024,11 @@ "PreferredIPVersion", "PrivateEndpointConnectionProvisioningState", "PrivateEndpointServiceConnectionStatus", + "ProductAuthType", "ProductState", "Protocol", "PublicNetworkAccess", + "ReleaseChannel", "ResourceSkuCapacityScaleType", "SamplingType", "SchemaType", 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/_enums.py similarity index 75% rename from sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_api_management_client_enums.py rename to sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_enums.py index 8d9ebef387a5..90053e38e784 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/_enums.py @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -11,10 +12,12 @@ class AccessIdName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessIdName.""" + """Type of AccessIdName.""" ACCESS = "access" + """ACCESS.""" GIT_ACCESS = "gitAccess" + """GIT_ACCESS.""" class AccessType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -50,22 +53,29 @@ class ApiManagementSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnum """The scale type applicable to the sku.""" AUTOMATIC = "Automatic" + """AUTOMATIC.""" MANUAL = "Manual" + """MANUAL.""" NONE = "None" + """NONE.""" class ApiManagementSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for restriction.""" QUOTA_ID = "QuotaId" + """QUOTA_ID.""" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + """NOT_AVAILABLE_FOR_SUBSCRIPTION.""" class ApiManagementSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of restrictions.""" LOCATION = "Location" + """LOCATION.""" ZONE = "Zone" + """ZONE.""" class ApimIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -75,24 +85,34 @@ class ApimIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ SYSTEM_ASSIGNED = "SystemAssigned" + """SYSTEM_ASSIGNED.""" USER_ASSIGNED = "UserAssigned" + """USER_ASSIGNED.""" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + """SYSTEM_ASSIGNED_USER_ASSIGNED.""" NONE = "None" + """NONE.""" class ApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of API.""" HTTP = "http" + """HTTP.""" SOAP = "soap" + """SOAP.""" WEBSOCKET = "websocket" + """WEBSOCKET.""" GRAPHQL = "graphql" + """GRAPHQL.""" ODATA = "odata" + """ODATA.""" GRPC = "grpc" + """GRPC.""" class AppType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AppType.""" + """Type of AppType.""" PORTAL = "portal" """User create request was sent by legacy developer portal.""" @@ -104,42 +124,45 @@ class AsyncOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of an async operation.""" STARTED = "Started" + """STARTED.""" IN_PROGRESS = "InProgress" + """IN_PROGRESS.""" SUCCEEDED = "Succeeded" + """SUCCEEDED.""" FAILED = "Failed" - - -class AsyncResolverStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Status of an async resolver.""" - - STARTED = "Started" - IN_PROGRESS = "InProgress" - SUCCEEDED = "Succeeded" - FAILED = "Failed" + """FAILED.""" class AuthorizationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AuthorizationMethod.""" + """Type of AuthorizationMethod.""" HEAD = "HEAD" + """HEAD.""" OPTIONS = "OPTIONS" + """OPTIONS.""" TRACE = "TRACE" + """TRACE.""" GET = "GET" + """GET.""" POST = "POST" + """POST.""" PUT = "PUT" + """PUT.""" PATCH = "PATCH" + """PATCH.""" DELETE = "DELETE" + """DELETE.""" class AuthorizationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Authorization type options.""" O_AUTH2 = "OAuth2" - """OAuth2 authorization type""" + """OAuth2 authorization type.""" class BackendProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Backend communication protocol.""" + """Backend communication protocol. Required when backend type is 'Single'.""" HTTP = "http" """The Backend is a RESTful service.""" @@ -147,59 +170,116 @@ class BackendProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Backend is a SOAP service.""" +class BackendSessionIdSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Source from where the session id is extracted.""" + + COOKIE = "cookie" + """The session id is set by APIM gateway in a cookie and is extracted from the cookies in client + requests.""" + + class BackendType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the backend. A backend can be either Single or Pool.""" SINGLE = "Single" - """supports single backend""" + """supports single backend.""" POOL = "Pool" - """supports pool backend""" + """supports pool backend.""" class BearerTokenSendingMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """BearerTokenSendingMethod.""" + """Type of BearerTokenSendingMethod.""" AUTHORIZATION_HEADER = "authorizationHeader" + """AUTHORIZATION_HEADER.""" QUERY = "query" + """QUERY.""" class BearerTokenSendingMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Form of an authorization grant, which the client uses to request the access token.""" AUTHORIZATION_HEADER = "authorizationHeader" - """Access token will be transmitted in the Authorization header using Bearer schema""" + """Access token will be transmitted in the Authorization header using Bearer schema.""" QUERY = "query" """Access token will be transmitted as query parameters.""" +class CarbonEmissionCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scope 2 carbon emission preference for the backend. When specified, the load balancer will + optimize traffic flow by routing to regions that have carbon emission less than or equal to the + specified category. However, when all other backends are not available it will route traffic to + these regions anyway. This requires the backend to be attributed with 'azureRegion' + information. + """ + + VERY_LOW = "VeryLow" + """Carbon intensity of less than or equal to 150 grams COâ‚‚e per KWh.""" + LOW = "Low" + """Carbon intensity between 151 & 300 (incl) grams COâ‚‚e per KWh.""" + MEDIUM = "Medium" + """Carbon intensity between 301 & 500 (incl) grams COâ‚‚e per KWh.""" + HIGH = "High" + """Carbon intensity between 501 & 700 (incl) grams COâ‚‚e per KWh.""" + VERY_HIGH = "VeryHigh" + """Carbon intensity of more than 700 grams COâ‚‚e per KWh.""" + + class CertificateConfigurationStoreName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only Root and CertificateAuthority are valid locations. """ CERTIFICATE_AUTHORITY = "CertificateAuthority" + """CERTIFICATE_AUTHORITY.""" ROOT = "Root" + """ROOT.""" class CertificateSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Certificate Source.""" MANAGED = "Managed" + """MANAGED.""" KEY_VAULT = "KeyVault" + """KEY_VAULT.""" CUSTOM = "Custom" + """CUSTOM.""" BUILT_IN = "BuiltIn" + """BUILT_IN.""" class CertificateStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Certificate Status.""" COMPLETED = "Completed" + """COMPLETED.""" FAILED = "Failed" + """FAILED.""" IN_PROGRESS = "InProgress" + """IN_PROGRESS.""" + + +class ClientApplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Client application state. The value derives the state of an application based on the statuses + of its associated ClientApplicationProductLinks. + """ + + PENDING = "pending" + """If there are no associated ClientApplicationLinks or all ClientApplicationLinks are in a state + that doesn't meet the criteria for the states: active, rejected, approved (e.g., a mix of + active and rejected without any approved).""" + ACTIVE = "active" + """If there are no approved ClientApplicationLink, but at least one ClientApplicationLink is + active, the Application is considered active.""" + REJECTED = "rejected" + """If all ClientApplicationLinks are rejected, the Application is considered rejected.""" + APPROVED = "approved" + """If at least one ClientApplicationLink is approved, the Application is considered approved.""" class ClientAuthenticationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ClientAuthenticationMethod.""" + """Type of ClientAuthenticationMethod.""" BASIC = "Basic" """Basic Client Authentication method.""" @@ -208,9 +288,10 @@ class ClientAuthenticationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): class ConfigurationIdName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ConfigurationIdName.""" + """Type of ConfigurationIdName.""" CONFIGURATION = "configuration" + """CONFIGURATION.""" class Confirmation(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -226,9 +307,13 @@ class ConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The connection status.""" UNKNOWN = "Unknown" + """UNKNOWN.""" CONNECTED = "Connected" + """CONNECTED.""" DISCONNECTED = "Disconnected" + """DISCONNECTED.""" DEGRADED = "Degraded" + """DEGRADED.""" class ConnectivityCheckProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -237,16 +322,22 @@ class ConnectivityCheckProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ TCP = "TCP" + """TCP.""" HTTP = "HTTP" + """HTTP.""" HTTPS = "HTTPS" + """HTTPS.""" class ConnectivityStatusType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Resource Connectivity Status Type identifier.""" INITIALIZING = "initializing" + """INITIALIZING.""" SUCCESS = "success" + """SUCCESS.""" FAILURE = "failure" + """FAILURE.""" class ContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -287,12 +378,16 @@ class ContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource.""" + """The kind of entity that created the resource.""" USER = "User" + """The entity was created by a user.""" APPLICATION = "Application" + """The entity was created by an application.""" MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" KEY = "Key" + """The entity was created by a key.""" class DataMaskingMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -314,19 +409,20 @@ class DeveloperPortalStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): class ExportApi(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExportApi.""" + """Type of ExportApi.""" TRUE = "true" + """TRUE.""" class ExportFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExportFormat.""" + """Type of ExportFormat.""" SWAGGER = "swagger-link" """Export the Api Definition in OpenAPI 2.0 Specification as JSON document to the Storage Blob.""" WSDL = "wsdl-link" """Export the Api Definition in WSDL Schema to Storage Blob. This is only supported for APIs of - Type ``soap``""" + Type ``soap``.""" WADL = "wadl-link" """Export the Api Definition in WADL Schema to Storage Blob.""" OPENAPI = "openapi-link" @@ -342,16 +438,18 @@ class ExportResultFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): SWAGGER = "swagger-link-json" """The API Definition is exported in OpenAPI Specification 2.0 format to the Storage Blob.""" - WSDL = "wsdl-link+xml" - """The API Definition is exported in WSDL Schema to Storage Blob. This is only supported for APIs - of Type ``soap``""" WADL = "wadl-link-json" """Export the API Definition in WADL Schema to Storage Blob.""" + WSDL = "wsdl-link+xml" + """The API Definition is exported in WSDL Schema to Storage Blob. This is only supported for APIs + of Type ``soap``.""" OPEN_API = "openapi-link" """Export the API Definition in OpenAPI Specification 3.0 to Storage Blob.""" -class GatewayListDebugCredentialsContractPurpose(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class GatewayListDebugCredentialsContractPurpose( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): """Purpose of debug credential.""" TRACING = "tracing" @@ -370,36 +468,49 @@ class GatewaySkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class GrantType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """GrantType.""" + """Type of GrantType.""" AUTHORIZATION_CODE = "authorizationCode" - """Authorization Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.1.""" + """Authorization Code Grant flow as described `https://tools.ietf.org/html/rfc6749#section-4.1 + `_.""" IMPLICIT = "implicit" - """Implicit Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.2.""" + """Implicit Code Grant flow as described `https://tools.ietf.org/html/rfc6749#section-4.2 + `_.""" RESOURCE_OWNER_PASSWORD = "resourceOwnerPassword" """Resource Owner Password Grant flow as described - https://tools.ietf.org/html/rfc6749#section-4.3.""" + `https://tools.ietf.org/html/rfc6749#section-4.3 + `_.""" CLIENT_CREDENTIALS = "clientCredentials" - """Client Credentials Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.4.""" + """Client Credentials Grant flow as described `https://tools.ietf.org/html/rfc6749#section-4.4 + `_.""" class GroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Group type.""" CUSTOM = "custom" + """CUSTOM.""" SYSTEM = "system" + """SYSTEM.""" EXTERNAL = "external" + """EXTERNAL.""" class HostnameType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Hostname type.""" PROXY = "Proxy" + """PROXY.""" PORTAL = "Portal" + """PORTAL.""" MANAGEMENT = "Management" + """MANAGEMENT.""" SCM = "Scm" + """SCM.""" DEVELOPER_PORTAL = "DeveloperPortal" + """DEVELOPER_PORTAL.""" CONFIGURATION_API = "ConfigurationApi" + """CONFIGURATION_API.""" class HttpCorrelationProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -409,13 +520,15 @@ class HttpCorrelationProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Do not read and inject correlation headers.""" LEGACY = "Legacy" """Inject Request-Id and Request-Context headers with request correlation data. See - https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md.""" + `https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md + `_.""" W3_C = "W3C" - """Inject Trace Context headers. See https://w3c.github.io/trace-context.""" + """Inject Trace Context headers. See `https://w3c.github.io/trace-context + `_.""" class IdentityProviderType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """IdentityProviderType.""" + """Type of IdentityProviderType.""" FACEBOOK = "facebook" """Facebook as Identity provider.""" @@ -435,30 +548,50 @@ class IssueType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of issue.""" UNKNOWN = "Unknown" + """UNKNOWN.""" AGENT_STOPPED = "AgentStopped" + """AGENT_STOPPED.""" GUEST_FIREWALL = "GuestFirewall" + """GUEST_FIREWALL.""" DNS_RESOLUTION = "DnsResolution" + """DNS_RESOLUTION.""" SOCKET_BIND = "SocketBind" + """SOCKET_BIND.""" NETWORK_SECURITY_RULE = "NetworkSecurityRule" + """NETWORK_SECURITY_RULE.""" USER_DEFINED_ROUTE = "UserDefinedRoute" + """USER_DEFINED_ROUTE.""" PORT_THROTTLED = "PortThrottled" + """PORT_THROTTLED.""" PLATFORM = "Platform" + """PLATFORM.""" class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Key to be used to generate token for user.""" PRIMARY = "primary" + """PRIMARY.""" SECONDARY = "secondary" + """SECONDARY.""" + + +class KeyVaultFetchCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The last status of the Key Vault certificate fetch process.""" + + SUCCESS = "Success" + """SUCCESS.""" + FAILED = "Failed" + """FAILED.""" class KeyVaultRefreshState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """KeyVaultRefreshState.""" + """Type of KeyVaultRefreshState.""" TRUE = "true" """Entities for which KeyVault refresh failed.""" FALSE = "false" - """Entities for which KeyVault refresh succeeded""" + """Entities for which KeyVault refresh succeeded.""" class LegacyApiState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -485,6 +618,22 @@ class LegacyPortalStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Legacy Portal is disabled for the service.""" +class LlmDiagnosticSettings(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of LlmDiagnosticSettings.""" + + ENABLED = "enabled" + """Default LLM logs are enabled.""" + DISABLED = "disabled" + """Default LLM logs are disabled.""" + + +class LlmMessageLogTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of LlmMessageLogTypes.""" + + ALL = "all" + """Log all messages.""" + + class LoggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Logger type.""" @@ -493,14 +642,31 @@ class LoggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): APPLICATION_INSIGHTS = "applicationInsights" """Azure Application Insights as log destination.""" AZURE_MONITOR = "azureMonitor" - """Azure Monitor""" + """Azure Monitor.""" + + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity (where both SystemAssigned and UserAssigned types are + allowed). + """ + + NONE = "None" + """No managed identity.""" + SYSTEM_ASSIGNED = "SystemAssigned" + """System assigned managed identity.""" + USER_ASSIGNED = "UserAssigned" + """User assigned managed identity.""" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + """System and user assigned managed identity.""" class Method(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The HTTP method to be used.""" GET = "GET" + """GET.""" POST = "POST" + """POST.""" class MigrateToStv2Mode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -522,8 +688,11 @@ class NameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ VALID = "Valid" + """VALID.""" INVALID = "Invalid" + """INVALID.""" ALREADY_EXISTS = "AlreadyExists" + """ALREADY_EXISTS.""" class NatGatewayState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -536,7 +705,7 @@ class NatGatewayState(str, Enum, metaclass=CaseInsensitiveEnumMeta): class NotificationName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """NotificationName.""" + """Type of NotificationName.""" REQUEST_PUBLISHER_NOTIFICATION_MESSAGE = "RequestPublisherNotificationMessage" """The following email recipients and users will receive email notifications about subscription @@ -564,26 +733,29 @@ class OAuth2GrantType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """OAuth2 grant type options.""" AUTHORIZATION_CODE = "AuthorizationCode" - """Authorization Code grant""" + """Authorization Code grant.""" CLIENT_CREDENTIALS = "ClientCredentials" - """Client Credential grant""" + """Client Credential grant.""" class OperationNameFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The format of the Operation Name for Application Insights telemetries. Default is Name.""" NAME = "Name" - """API_NAME;rev=API_REVISION - OPERATION_NAME""" + """API_NAME;rev=API_REVISION - OPERATION_NAME.""" URL = "Url" - """HTTP_VERB URL""" + """HTTP_VERB URL.""" class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The origin of the issue.""" LOCAL = "Local" + """LOCAL.""" INBOUND = "Inbound" + """INBOUND.""" OUTBOUND = "Outbound" + """OUTBOUND.""" class PlatformVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -628,7 +800,7 @@ class PolicyContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): class PolicyExportFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PolicyExportFormat.""" + """Type of PolicyExportFormat.""" XML = "xml" """The contents are inline and Content type is an XML document.""" @@ -637,7 +809,7 @@ class PolicyExportFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): class PolicyFragmentContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PolicyFragmentContentFormat.""" + """Type of PolicyFragmentContentFormat.""" XML = "xml" """The contents are inline and Content type is an XML document.""" @@ -646,28 +818,34 @@ class PolicyFragmentContentFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): class PolicyIdName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PolicyIdName.""" + """Type of PolicyIdName.""" POLICY = "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""" + """The policy is required to have base policy.""" FALSE = "false" - """The policy does not require to have base policy""" + """The policy does not require to have base policy.""" class PolicyScopeContract(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PolicyScopeContract.""" + """Type of PolicyScopeContract.""" TENANT = "Tenant" + """TENANT.""" PRODUCT = "Product" + """PRODUCT.""" API = "Api" + """API.""" OPERATION = "Operation" + """OPERATION.""" ALL = "All" + """ALL.""" class PortalRevisionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -698,23 +876,42 @@ class PreferredIPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The IP version to be used. Only IPv4 is supported for now.""" I_PV4 = "IPv4" + """I_PV4.""" -class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class PrivateEndpointConnectionProvisioningState( # pylint: disable=name-too-long + str, Enum, metaclass=CaseInsensitiveEnumMeta +): """The current provisioning state.""" SUCCEEDED = "Succeeded" + """Connection has been provisioned.""" CREATING = "Creating" + """Connection is being created.""" DELETING = "Deleting" + """Connection is being deleted.""" FAILED = "Failed" + """Connection provisioning has failed.""" class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status.""" PENDING = "Pending" + """Connection waiting for approval or rejection.""" APPROVED = "Approved" + """Connection approved.""" REJECTED = "Rejected" + """Connection Rejected.""" + + +class ProductAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ProductAuthType.""" + + SUBSCRIPTION_KEY = "subscription-key" + """SUBSCRIPTION_KEY.""" + APPLICATION_TOKEN = "application-token" + """APPLICATION_TOKEN.""" class ProductState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -724,16 +921,22 @@ class ProductState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ NOT_PUBLISHED = "notPublished" + """NOT_PUBLISHED.""" PUBLISHED = "published" + """PUBLISHED.""" class Protocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Protocol.""" + """Type of Protocol.""" HTTP = "http" + """HTTP.""" HTTPS = "https" + """HTTPS.""" WS = "ws" + """WS.""" WSS = "wss" + """WSS.""" class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -743,7 +946,20 @@ class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ENABLED = "Enabled" + """ENABLED.""" DISABLED = "Disabled" + """DISABLED.""" + + +class ReleaseChannel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Release Channel of this API Management service.""" + + PREVIEW = "Preview" + """Preview Channel of the service.""" + DEFAULT = "Default" + """Default Channel of the service.""" + STABLE = "Stable" + """Stable Channel of the service.""" class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -774,16 +990,19 @@ class SchemaType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class SettingsTypeName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SettingsTypeName.""" + """Type of SettingsTypeName.""" PUBLIC = "public" + """PUBLIC.""" class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The severity of the issue.""" ERROR = "Error" + """ERROR.""" WARNING = "Warning" + """WARNING.""" class SkuType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -805,17 +1024,18 @@ class SkuType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """BasicV2 SKU of Api Management.""" STANDARD_V2 = "StandardV2" """StandardV2 SKU of Api Management.""" + PREMIUM_V2 = "PremiumV2" + """PremiumV2 SKU of Api Management.""" class SoapApiType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of API to create. - - * ``http`` creates a REST API - * ``soap`` creates a SOAP pass-through API - * ``websocket`` creates websocket API - * ``graphql`` creates GraphQL API. - New types can be added in the future. + * `http` creates a REST API + * `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" @@ -857,30 +1077,50 @@ class SubscriptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ SUSPENDED = "suspended" + """SUSPENDED.""" ACTIVE = "active" + """ACTIVE.""" EXPIRED = "expired" + """EXPIRED.""" SUBMITTED = "submitted" + """SUBMITTED.""" REJECTED = "rejected" + """REJECTED.""" CANCELLED = "cancelled" + """CANCELLED.""" class TemplateName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """TemplateName.""" + """Type of TemplateName.""" APPLICATION_APPROVED_NOTIFICATION_MESSAGE = "applicationApprovedNotificationMessage" + """APPLICATION_APPROVED_NOTIFICATION_MESSAGE.""" ACCOUNT_CLOSED_DEVELOPER = "accountClosedDeveloper" + """ACCOUNT_CLOSED_DEVELOPER.""" QUOTA_LIMIT_APPROACHING_DEVELOPER_NOTIFICATION_MESSAGE = "quotaLimitApproachingDeveloperNotificationMessage" + """QUOTA_LIMIT_APPROACHING_DEVELOPER_NOTIFICATION_MESSAGE.""" NEW_DEVELOPER_NOTIFICATION_MESSAGE = "newDeveloperNotificationMessage" + """NEW_DEVELOPER_NOTIFICATION_MESSAGE.""" EMAIL_CHANGE_IDENTITY_DEFAULT = "emailChangeIdentityDefault" + """EMAIL_CHANGE_IDENTITY_DEFAULT.""" INVITE_USER_NOTIFICATION_MESSAGE = "inviteUserNotificationMessage" + """INVITE_USER_NOTIFICATION_MESSAGE.""" NEW_COMMENT_NOTIFICATION_MESSAGE = "newCommentNotificationMessage" + """NEW_COMMENT_NOTIFICATION_MESSAGE.""" CONFIRM_SIGN_UP_IDENTITY_DEFAULT = "confirmSignUpIdentityDefault" + """CONFIRM_SIGN_UP_IDENTITY_DEFAULT.""" NEW_ISSUE_NOTIFICATION_MESSAGE = "newIssueNotificationMessage" + """NEW_ISSUE_NOTIFICATION_MESSAGE.""" PURCHASE_DEVELOPER_NOTIFICATION_MESSAGE = "purchaseDeveloperNotificationMessage" + """PURCHASE_DEVELOPER_NOTIFICATION_MESSAGE.""" PASSWORD_RESET_IDENTITY_DEFAULT = "passwordResetIdentityDefault" + """PASSWORD_RESET_IDENTITY_DEFAULT.""" PASSWORD_RESET_BY_ADMIN_NOTIFICATION_MESSAGE = "passwordResetByAdminNotificationMessage" + """PASSWORD_RESET_BY_ADMIN_NOTIFICATION_MESSAGE.""" REJECT_DEVELOPER_NOTIFICATION_MESSAGE = "rejectDeveloperNotificationMessage" + """REJECT_DEVELOPER_NOTIFICATION_MESSAGE.""" REQUEST_DEVELOPER_NOTIFICATION_MESSAGE = "requestDeveloperNotificationMessage" + """REQUEST_DEVELOPER_NOTIFICATION_MESSAGE.""" class TranslateRequiredQueryParametersConduct(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -889,7 +1129,7 @@ class TranslateRequiredQueryParametersConduct(str, Enum, metaclass=CaseInsensiti """ TEMPLATE = "template" - """Translates required query parameters to template ones. Is a default value""" + """Translates required query parameters to template ones. Is a default value.""" QUERY = "query" """Leaves required query parameters as they are (no translation done).""" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py new file mode 100644 index 000000000000..2e945ffe98b0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py @@ -0,0 +1,21629 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_field + +if TYPE_CHECKING: + from .. import models as _models + + +class Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + """ + + +class AccessInformationContract(ProxyResource): + """Tenant Settings. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: AccessInformation entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.AccessInformationContractProperties + """ + + properties: Optional["_models.AccessInformationContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """AccessInformation entity contract properties.""" + + __flattened_items = ["id", "principal_id", "enabled"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AccessInformationContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AccessInformationContractProperties(_Model): + """Tenant access information contract of the API Management service. + + :ivar id: Access Information type ('access' or 'gitAccess'). + :vartype id: str + :ivar principal_id: Principal (User) Identifier. + :vartype principal_id: str + :ivar enabled: Determines whether direct access is enabled. + :vartype enabled: bool + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Access Information type ('access' or 'gitAccess').""" + principal_id: Optional[str] = rest_field( + name="principalId", visibility=["read", "create", "update", "delete", "query"] + ) + """Principal (User) Identifier.""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Determines whether direct access is enabled.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + principal_id: Optional[str] = None, + enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccessInformationCreateParameterProperties(_Model): # pylint: disable=name-too-long + """Tenant access information update parameters of the API Management service. + + :ivar principal_id: Principal (User) Identifier. + :vartype principal_id: str + :ivar primary_key: Primary access key. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :vartype primary_key: str + :ivar secondary_key: Secondary access key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :vartype secondary_key: str + :ivar enabled: Determines whether direct access is enabled. + :vartype enabled: bool + """ + + principal_id: Optional[str] = rest_field( + name="principalId", visibility=["read", "create", "update", "delete", "query"] + ) + """Principal (User) Identifier.""" + primary_key: Optional[str] = rest_field( + name="primaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Primary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' + POST request to get the value.""" + secondary_key: Optional[str] = rest_field( + name="secondaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Secondary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' + POST request to get the value.""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Determines whether direct access is enabled.""" + + @overload + def __init__( + self, + *, + principal_id: Optional[str] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccessInformationCreateParameters(_Model): + """Tenant access information update parameters. + + :ivar properties: Tenant access information update parameter properties. + :vartype properties: + ~azure.mgmt.apimanagement.models.AccessInformationCreateParameterProperties + """ + + properties: Optional["_models.AccessInformationCreateParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tenant access information update parameter properties.""" + + __flattened_items = ["principal_id", "primary_key", "secondary_key", "enabled"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AccessInformationCreateParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AccessInformationSecretsContract(_Model): + """Tenant access information contract of the API Management service. + + :ivar id: Access Information type ('access' or 'gitAccess'). + :vartype id: str + :ivar principal_id: Principal (User) Identifier. + :vartype principal_id: str + :ivar primary_key: Primary access key. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :vartype primary_key: str + :ivar secondary_key: Secondary access key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :vartype secondary_key: str + :ivar enabled: Determines whether direct access is enabled. + :vartype enabled: bool + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Access Information type ('access' or 'gitAccess').""" + principal_id: Optional[str] = rest_field( + name="principalId", visibility=["read", "create", "update", "delete", "query"] + ) + """Principal (User) Identifier.""" + primary_key: Optional[str] = rest_field( + name="primaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Primary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' + POST request to get the value.""" + secondary_key: Optional[str] = rest_field( + name="secondaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Secondary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' + POST request to get the value.""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Determines whether direct access is enabled.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + principal_id: Optional[str] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccessInformationUpdateParameterProperties(_Model): # pylint: disable=name-too-long + """Tenant access information update parameters of the API Management service. + + :ivar enabled: Determines whether direct access is enabled. + :vartype enabled: bool + """ + + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Determines whether direct access is enabled.""" + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AccessInformationUpdateParameters(_Model): + """Tenant access information update parameters. + + :ivar properties: Tenant access information update parameter properties. + :vartype properties: + ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameterProperties + """ + + properties: Optional["_models.AccessInformationUpdateParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tenant access information update parameter properties.""" + + __flattened_items = ["enabled"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AccessInformationUpdateParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AdditionalLocation(_Model): + """Description of an additional API Management resource location. + + :ivar location: The location name of the additional region among Azure Data center regions. + Required. + :vartype location: str + :ivar sku: SKU properties of the API Management service. Required. + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :ivar zones: A list of availability zones denoting where the resource needs to come from. + :vartype zones: list[str] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in the additional location. Available only for Basic, Standard, Premium and Isolated + SKU. + :vartype public_ip_addresses: list[str] + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service which is deployed in an Internal Virtual Network in a particular additional location. + Available only for Basic, Standard, Premium and Isolated SKU. + :vartype private_ip_addresses: list[str] + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the location. Supported only for Premium SKU being deployed + in Virtual Network. + :vartype public_ip_address_id: str + :ivar virtual_network_configuration: Virtual network configuration for the location. + :vartype virtual_network_configuration: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :ivar gateway_regional_url: Gateway URL of the API Management service in the Region. + :vartype gateway_regional_url: str + :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management + service. Known values are: "Enabled" and "Disabled". + :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState + :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT + Gateway deployed service. Available only for Premium SKU on stv2 platform. + :vartype outbound_public_ip_addresses: list[str] + :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple + 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", "mtv1", and "stv2.1". + :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion + """ + + location: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The location name of the additional region among Azure Data center regions. Required.""" + sku: "_models.ApiManagementServiceSkuProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """SKU properties of the API Management service. Required.""" + zones: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A list of availability zones denoting where the resource needs to come from.""" + public_ip_addresses: Optional[list[str]] = rest_field(name="publicIPAddresses", visibility=["read"]) + """Public Static Load Balanced IP addresses of the API Management service in the additional + location. Available only for Basic, Standard, Premium and Isolated SKU.""" + private_ip_addresses: Optional[list[str]] = rest_field(name="privateIPAddresses", visibility=["read"]) + """Private Static Load Balanced IP addresses of the API Management service which is deployed in an + Internal Virtual Network in a particular additional location. Available only for Basic, + Standard, Premium and Isolated SKU.""" + public_ip_address_id: Optional[str] = rest_field( + name="publicIpAddressId", visibility=["read", "create", "update", "delete", "query"] + ) + """Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed + service in the location. Supported only for Premium SKU being deployed in Virtual Network.""" + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = rest_field( + name="virtualNetworkConfiguration", visibility=["read", "create", "update", "delete", "query"] + ) + """Virtual network configuration for the location.""" + gateway_regional_url: Optional[str] = rest_field(name="gatewayRegionalUrl", visibility=["read"]) + """Gateway URL of the API Management service in the Region.""" + nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = rest_field( + name="natGatewayState", visibility=["read", "create", "update", "delete", "query"] + ) + """Property can be used to enable NAT Gateway for this API Management service. Known values are: + \"Enabled\" and \"Disabled\".""" + outbound_public_ip_addresses: Optional[list[str]] = rest_field( + name="outboundPublicIPAddresses", visibility=["read"] + ) + """Outbound public IPV4 address prefixes associated with NAT Gateway deployed service. Available + only for Premium SKU on stv2 platform.""" + disable_gateway: Optional[bool] = rest_field( + name="disableGateway", visibility=["read", "create", "update", "delete", "query"] + ) + """Property only valid for an Api Management service deployed in multiple locations. This can be + used to disable the gateway in this additional location.""" + platform_version: Optional[Union[str, "_models.PlatformVersion"]] = rest_field( + name="platformVersion", visibility=["read"] + ) + """Compute Platform Version running the service. Known values are: \"undetermined\", \"stv1\", + \"stv2\", \"mtv1\", and \"stv2.1\".""" + + @overload + def __init__( + self, + *, + location: str, + sku: "_models.ApiManagementServiceSkuProperties", + zones: Optional[list[str]] = None, + public_ip_address_id: Optional[str] = None, + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, + nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, + disable_gateway: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AllPoliciesContract(ProxyResource): + """AllPolicies Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the All Policies. + :vartype properties: ~azure.mgmt.apimanagement.models.AllPoliciesContractProperties + """ + + properties: Optional["_models.AllPoliciesContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the All Policies.""" + + __flattened_items = ["reference_policy_id", "compliance_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AllPoliciesContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AllPoliciesContractProperties(_Model): + """AllPolicies Properties. + + :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 + """ + + reference_policy_id: Optional[str] = rest_field( + name="referencePolicyId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy Identifier.""" + compliance_state: Optional[Union[str, "_models.PolicyComplianceState"]] = rest_field( + name="complianceState", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy Restriction Compliance State. Known values are: \"Pending\", \"NonCompliant\", and + \"Compliant\".""" + + @overload + def __init__( + self, + *, + reference_policy_id: Optional[str] = None, + compliance_state: Optional[Union[str, "_models.PolicyComplianceState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiContactInformation(_Model): + """API contact information. + + :ivar name: The identifying name of the contact person/organization. + :vartype name: str + :ivar url: The URL pointing to the contact information. MUST be in the format of a URL. + :vartype url: str + :ivar email: The email address of the contact person/organization. MUST be in the format of an + email address. + :vartype email: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The identifying name of the contact person/organization.""" + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The URL pointing to the contact information. MUST be in the format of a URL.""" + email: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The email address of the contact person/organization. MUST be in the format of an email + address.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + url: Optional[str] = None, + email: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiContract(ProxyResource): + """API details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: API entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiContractProperties + """ + + properties: Optional["_models.ApiContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """API entity contract properties.""" + + __flattened_items = [ + "description", + "authentication_settings", + "subscription_key_parameter_names", + "api_type", + "api_revision", + "api_version", + "is_current", + "is_online", + "api_revision_description", + "api_version_description", + "api_version_set_id", + "subscription_required", + "terms_of_service_url", + "contact", + "license", + "source_api_id", + "display_name", + "service_url", + "path", + "protocols", + "api_version_set", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ApiContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiEntityBaseContract(_Model): + """API base contract details. + + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :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", "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. + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool + :ivar is_online: Indicates if API revision is accessible via the gateway. + :vartype is_online: bool + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the API. May include HTML formatting tags.""" + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = rest_field( + name="authenticationSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of authentication settings included into this API.""" + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = rest_field( + name="subscriptionKeyParameterNames", visibility=["read", "create", "update", "delete", "query"] + ) + """Protocols over which API is made available.""" + api_type: Optional[Union[str, "_models.ApiType"]] = rest_field( + name="type", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of API. Known values are: \"http\", \"soap\", \"websocket\", \"graphql\", \"odata\", and + \"grpc\".""" + api_revision: Optional[str] = rest_field( + name="apiRevision", visibility=["read", "create", "update", "delete", "query"] + ) + """Describes the revision of the API. If no value is provided, default revision 1 is created.""" + api_version: Optional[str] = rest_field( + name="apiVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates the version identifier of the API if the API is versioned.""" + is_current: Optional[bool] = rest_field( + name="isCurrent", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if API revision is current api revision.""" + is_online: Optional[bool] = rest_field(name="isOnline", visibility=["read"]) + """Indicates if API revision is accessible via the gateway.""" + api_revision_description: Optional[str] = rest_field( + name="apiRevisionDescription", visibility=["read", "create", "update", "delete", "query"] + ) + """Description of the API Revision.""" + api_version_description: Optional[str] = rest_field( + name="apiVersionDescription", visibility=["read", "create", "update", "delete", "query"] + ) + """Description of the API Version.""" + api_version_set_id: Optional[str] = rest_field( + name="apiVersionSetId", visibility=["read", "create", "update", "delete", "query"] + ) + """A resource identifier for the related ApiVersionSet.""" + subscription_required: Optional[bool] = rest_field( + name="subscriptionRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether an API or Product subscription is required for accessing the API.""" + terms_of_service_url: Optional[str] = rest_field( + name="termsOfServiceUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """A URL to the Terms of Service for the API. MUST be in the format of a URL.""" + contact: Optional["_models.ApiContactInformation"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Contact information for the API.""" + license: Optional["_models.ApiLicenseInformation"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """License information for the API.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiContractProperties(ApiEntityBaseContract): + """API Entity Properties. + + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :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", "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. + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool + :ivar is_online: Indicates if API revision is accessible via the gateway. + :vartype is_online: bool + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar source_api_id: API identifier of the source API. + :vartype source_api_id: str + :ivar display_name: API name. Must be 1 to 300 characters long. + :vartype display_name: str + :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. + :vartype service_url: str + :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the + API Management service instance. It is appended to the API endpoint base URL specified during + the service instance creation to form a public URL for this API. Required. + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :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 + """ + + source_api_id: Optional[str] = rest_field( + name="sourceApiId", visibility=["read", "create", "update", "delete", "query"] + ) + """API identifier of the source API.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """API name. Must be 1 to 300 characters long.""" + service_url: Optional[str] = rest_field( + name="serviceUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters + long.""" + path: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Relative URL uniquely identifying this API and all of its resource paths within the API + Management service instance. It is appended to the API endpoint base URL specified during the + service instance creation to form a public URL for this API. Required.""" + protocols: Optional[list[Union[str, "_models.Protocol"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes on which protocols the operations in this API can be invoked.""" + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = rest_field( + name="apiVersionSet", visibility=["read", "create", "update", "delete", "query"] + ) + """Version set details.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The provisioning state.""" + + @overload + def __init__( + self, + *, + path: str, + description: Optional[str] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, + source_api_id: Optional[str] = None, + display_name: Optional[str] = None, + service_url: Optional[str] = None, + protocols: Optional[list[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiContractUpdateProperties(ApiEntityBaseContract): + """API update contract properties. + + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :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", "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. + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool + :ivar is_online: Indicates if API revision is accessible via the gateway. + :vartype is_online: bool + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar display_name: API name. + :vartype display_name: str + :ivar service_url: Absolute URL of the backend service implementing this API. + :vartype service_url: str + :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the + API Management service instance. It is appended to the API endpoint base URL specified during + the service instance creation to form a public URL for this API. + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """API name.""" + service_url: Optional[str] = rest_field( + name="serviceUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """Absolute URL of the backend service implementing this API.""" + path: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Relative URL uniquely identifying this API and all of its resource paths within the API + Management service instance. It is appended to the API endpoint base URL specified during the + service instance creation to form a public URL for this API.""" + protocols: Optional[list[Union[str, "_models.Protocol"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes on which protocols the operations in this API can be invoked.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, + display_name: Optional[str] = None, + service_url: Optional[str] = None, + path: Optional[str] = None, + protocols: Optional[list[Union[str, "_models.Protocol"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiCreateOrUpdateParameter(_Model): + """API Create or Update Parameters. + + :ivar properties: API entity create of update properties. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateProperties + """ + + properties: Optional["_models.ApiCreateOrUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """API entity create of update properties.""" + + __flattened_items = [ + "description", + "authentication_settings", + "subscription_key_parameter_names", + "api_type", + "api_revision", + "api_version", + "is_current", + "is_online", + "api_revision_description", + "api_version_description", + "api_version_set_id", + "subscription_required", + "terms_of_service_url", + "contact", + "license", + "source_api_id", + "display_name", + "service_url", + "path", + "protocols", + "api_version_set", + "provisioning_state", + "value", + "format", + "wsdl_selector", + "soap_api_type", + "translate_required_query_parameters_conduct", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ApiCreateOrUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiCreateOrUpdateProperties(ApiContractProperties): + """API Create or Update Properties. + + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :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", "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. + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool + :ivar is_online: Indicates if API revision is accessible via the gateway. + :vartype is_online: bool + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar source_api_id: API identifier of the source API. + :vartype source_api_id: str + :ivar display_name: API name. Must be 1 to 300 characters long. + :vartype display_name: str + :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. + :vartype service_url: str + :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the + API Management service instance. It is appended to the API endpoint base URL specified during + the service instance creation to form a public URL for this API. Required. + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :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. 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: + ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector + :ivar soap_api_type: Type of API to create. + + * `http` creates a REST API + * `soap` creates a SOAP pass-through API + * `websocket` creates websocket API + * `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', + 'query'. Known values are: "template" and "query". + :vartype translate_required_query_parameters_conduct: str or + ~azure.mgmt.apimanagement.models.TranslateRequiredQueryParametersConduct + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Content value when Importing an API.""" + format: Optional[Union[str, "_models.ContentFormat"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """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\".""" + wsdl_selector: Optional["_models.ApiCreateOrUpdatePropertiesWsdlSelector"] = rest_field( + name="wsdlSelector", visibility=["read", "create", "update", "delete", "query"] + ) + """Criteria to limit import of WSDL to a subset of the document.""" + soap_api_type: Optional[Union[str, "_models.SoapApiType"]] = rest_field( + name="apiType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of API to create. + + * `http` creates a REST API + * `soap` creates a SOAP pass-through API + * `websocket` creates websocket API + * `graphql` creates GraphQL API. + New types can be added in the future. Known values are: \"http\", \"soap\", \"websocket\", + \"graphql\", \"odata\", and \"grpc\".""" + translate_required_query_parameters_conduct: Optional[ + Union[str, "_models.TranslateRequiredQueryParametersConduct"] + ] = rest_field(name="translateRequiredQueryParameters", visibility=["read", "create", "update", "delete", "query"]) + """Strategy of translating required query parameters to template ones. By default has value + 'template'. Possible values: 'template', 'query'. Known values are: \"template\" and \"query\".""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + path: str, + description: Optional[str] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, + source_api_id: Optional[str] = None, + display_name: Optional[str] = None, + service_url: Optional[str] = None, + protocols: Optional[list[Union[str, "_models.Protocol"]]] = None, + api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, + value: Optional[str] = None, + format: Optional[Union[str, "_models.ContentFormat"]] = None, + wsdl_selector: Optional["_models.ApiCreateOrUpdatePropertiesWsdlSelector"] = None, + soap_api_type: Optional[Union[str, "_models.SoapApiType"]] = None, + translate_required_query_parameters_conduct: Optional[ + Union[str, "_models.TranslateRequiredQueryParametersConduct"] + ] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiCreateOrUpdatePropertiesWsdlSelector(_Model): + """Criteria to limit import of WSDL to a subset of the document. + + :ivar wsdl_service_name: Name of service to import from WSDL. + :vartype wsdl_service_name: str + :ivar wsdl_endpoint_name: Name of endpoint(port) to import from WSDL. + :vartype wsdl_endpoint_name: str + """ + + wsdl_service_name: Optional[str] = rest_field( + name="wsdlServiceName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of service to import from WSDL.""" + wsdl_endpoint_name: Optional[str] = rest_field( + name="wsdlEndpointName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of endpoint(port) to import from WSDL.""" + + @overload + def __init__( + self, + *, + wsdl_service_name: Optional[str] = None, + wsdl_endpoint_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiExportResult(_Model): + """API Export result. + + :ivar id: ResourceId of the API which was exported. + :vartype id: str + :ivar export_result_format: Format in which the API Details are exported to the Storage Blob + with Sas Key valid for 5 minutes. Known values are: "swagger-link-json", "wadl-link-json", + "wsdl-link+xml", and "openapi-link". + :vartype export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat + :ivar value: The object defining the schema of the exported API Detail. + :vartype value: ~azure.mgmt.apimanagement.models.ApiExportResultValue + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """ResourceId of the API which was exported.""" + export_result_format: Optional[Union[str, "_models.ExportResultFormat"]] = rest_field( + name="format", visibility=["read", "create", "update", "delete", "query"] + ) + """Format in which the API Details are exported to the Storage Blob with Sas Key valid for 5 + minutes. Known values are: \"swagger-link-json\", \"wadl-link-json\", \"wsdl-link+xml\", and + \"openapi-link\".""" + value: Optional["_models.ApiExportResultValue"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object defining the schema of the exported API Detail.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + export_result_format: Optional[Union[str, "_models.ExportResultFormat"]] = None, + value: Optional["_models.ApiExportResultValue"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiExportResultValue(_Model): + """The object defining the schema of the exported API Detail. + + :ivar link: Link to the Storage Blob containing the result of the export operation. The Blob + Uri is only valid for 5 minutes. + :vartype link: str + """ + + link: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Link to the Storage Blob containing the result of the export operation. The Blob Uri is only + valid for 5 minutes.""" + + @overload + def __init__( + self, + *, + link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiLicenseInformation(_Model): + """API license information. + + :ivar name: The license name used for the API. + :vartype name: str + :ivar url: A URL to the license used for the API. MUST be in the format of a URL. + :vartype url: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The license name used for the API.""" + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A URL to the license used for the API. MUST be in the format of a URL.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + url: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementGatewayBaseProperties(_Model): + """Base Properties of an API Management gateway resource description. + + :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 + """ + + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """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.""" + target_provisioning_state: Optional[str] = rest_field(name="targetProvisioningState", visibility=["read"]) + """The provisioning state of the API Management gateway, which is targeted by the long running + operation started on the gateway.""" + created_at_utc: Optional[datetime.datetime] = rest_field(name="createdAtUtc", visibility=["read"], format="rfc3339") + """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.""" + frontend: Optional["_models.FrontendConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Information regarding how the gateway should be exposed.""" + backend: Optional["_models.BackendConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Information regarding how the gateway should integrate with backend systems.""" + configuration_api: Optional["_models.GatewayConfigurationApi"] = rest_field( + name="configurationApi", visibility=["read", "create", "update", "delete", "query"] + ) + """Information regarding the Configuration API of the API Management gateway. This is only + applicable for API gateway with Standard SKU.""" + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = rest_field( + name="virtualNetworkType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of VPN in which API Management gateway needs to be configured in. Known values are: + \"None\", \"External\", and \"Internal\".""" + + @overload + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementGatewayConfigConnectionResource(ProxyResource): # pylint: disable=name-too-long + """A single API Management gateway resource in List or Get response. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the API Management gateway config connection. Required. + :vartype properties: ~azure.mgmt.apimanagement.models.GatewayConfigConnectionBaseProperties + :ivar etag: ETag of the resource. + :vartype etag: str + """ + + properties: "_models.GatewayConfigConnectionBaseProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API Management gateway config connection. Required.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """ETag of the resource.""" + + __flattened_items = ["provisioning_state", "source_id", "default_hostname", "hostnames"] + + @overload + def __init__( + self, + *, + properties: "_models.GatewayConfigConnectionBaseProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiManagementGatewayProperties(ApiManagementGatewayBaseProperties): + """Properties of an API Management gateway resource description. + + :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 + """ + + @overload + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TrackedResource(Resource): + """Tracked Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + location: str = rest_field(visibility=["read", "create"]) + """The geo-location where the resource lives. Required.""" + + @overload + def __init__( + self, + *, + location: str, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementGatewayResource(TrackedResource): + """A single API Management gateway resource in List or Get response. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Properties of the API Management gateway. Required. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiManagementGatewayProperties + :ivar sku: SKU properties of the API Management gateway. Required. + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementGatewaySkuProperties + :ivar etag: ETag of the resource. + :vartype etag: str + """ + + properties: "_models.ApiManagementGatewayProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API Management gateway. Required.""" + sku: "_models.ApiManagementGatewaySkuProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """SKU properties of the API Management gateway. Required.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """ETag of the resource.""" + + __flattened_items = [ + "provisioning_state", + "target_provisioning_state", + "created_at_utc", + "frontend", + "backend", + "configuration_api", + "virtual_network_type", + ] + + @overload + def __init__( + self, + *, + location: str, + properties: "_models.ApiManagementGatewayProperties", + sku: "_models.ApiManagementGatewaySkuProperties", + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiManagementGatewaySkuProperties(_Model): + """API Management gateway resource SKU properties. + + :ivar name: Name of the Sku. Required. Known values are: "Standard", + "WorkspaceGatewayStandard", and "WorkspaceGatewayPremium". + :vartype name: str or ~azure.mgmt.apimanagement.models.ApiGatewaySkuType + :ivar capacity: Capacity of the SKU (number of deployed units of the SKU). + :vartype capacity: int + """ + + name: Union[str, "_models.ApiGatewaySkuType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the Sku. Required. Known values are: \"Standard\", \"WorkspaceGatewayStandard\", and + \"WorkspaceGatewayPremium\".""" + capacity: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Capacity of the SKU (number of deployed units of the SKU).""" + + @overload + def __init__( + self, + *, + name: Union[str, "_models.ApiGatewaySkuType"], + capacity: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementGatewaySkuPropertiesForPatch(_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.ApiGatewaySkuType + :ivar capacity: Capacity of the SKU (number of deployed units of the SKU). + :vartype capacity: int + """ + + name: Optional[Union[str, "_models.ApiGatewaySkuType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the Sku. Known values are: \"Standard\", \"WorkspaceGatewayStandard\", and + \"WorkspaceGatewayPremium\".""" + capacity: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Capacity of the SKU (number of deployed units of the SKU).""" + + @overload + def __init__( + self, + *, + name: Optional[Union[str, "_models.ApiGatewaySkuType"]] = None, + capacity: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApimResource(_Model): + """The Resource definition. + + :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] + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Resource ID.""" + name: Optional[str] = rest_field(visibility=["read"]) + """Resource name.""" + type: Optional[str] = rest_field(visibility=["read"]) + """Resource type for API Management resource is set to Microsoft.ApiManagement.""" + tags: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource tags.""" + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementGatewayUpdateParameters(ApimResource): + """Parameter supplied to Update API Management gateway. + + :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 properties: Properties of the API Management gateway. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiManagementGatewayUpdateProperties + :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 + """ + + properties: Optional["_models.ApiManagementGatewayUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API Management gateway.""" + sku: Optional["_models.ApiManagementGatewaySkuPropertiesForPatch"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """SKU properties of the API Management gateway.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """ETag of the resource.""" + + __flattened_items = [ + "provisioning_state", + "target_provisioning_state", + "created_at_utc", + "frontend", + "backend", + "configuration_api", + "virtual_network_type", + ] + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ApiManagementGatewayUpdateProperties"] = None, + sku: Optional["_models.ApiManagementGatewaySkuPropertiesForPatch"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiManagementGatewayUpdateProperties(ApiManagementGatewayBaseProperties): + """Properties of an API Management gateway resource description. + + :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 + """ + + @overload + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceApplyNetworkConfigurationParameters(_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 + """ + + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """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.""" + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceBackupRestoreParameters(_Model): # pylint: disable=name-too-long + """Parameters supplied to the Backup/Restore of an API Management service operation. + + :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 + """ + + storage_account: str = rest_field(name="storageAccount", visibility=["read", "create", "update", "delete", "query"]) + """The name of the Azure storage account (used to place/retrieve the backup). Required.""" + container_name: str = rest_field(name="containerName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the blob container (used to place/retrieve the backup). Required.""" + backup_name: str = rest_field(name="backupName", visibility=["read", "create", "update", "delete", "query"]) + """The name of the backup file to create/retrieve. Required.""" + access_type: Optional[Union[str, "_models.AccessType"]] = rest_field( + name="accessType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of access to be used for the storage account. Known values are: \"AccessKey\", + \"SystemAssignedManagedIdentity\", and \"UserAssignedManagedIdentity\".""" + access_key: Optional[str] = rest_field(name="accessKey", visibility=["read", "create", "update", "delete", "query"]) + """Storage account access key. Required only if ``accessType`` is set to ``AccessKey``.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """The Client ID of user assigned managed identity. Required only if ``accessType`` is set to + ``UserAssignedManagedIdentity``.""" + + @overload + def __init__( + self, + *, + storage_account: str, + container_name: str, + backup_name: str, + access_type: Optional[Union[str, "_models.AccessType"]] = None, + access_key: Optional[str] = None, + client_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceBaseProperties(_Model): + """Base Properties of an API Management service resource description. + + :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 + :ivar target_provisioning_state: The provisioning state of the API Management service, which is + targeted by the long running operation started on the service. + :vartype target_provisioning_state: str + :ivar created_at_utc: Creation UTC date of the API Management service.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 gateway_url: Gateway URL of the API Management service. + :vartype gateway_url: str + :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. + :vartype gateway_regional_url: str + :ivar portal_url: Publisher portal endpoint Url of the API Management service. + :vartype portal_url: str + :ivar management_api_url: Management API endpoint URL of the API Management service. + :vartype management_api_url: str + :ivar scm_url: SCM endpoint URL of the API Management service. + :vartype scm_url: str + :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. + :vartype developer_portal_url: str + :ivar hostname_configurations: Custom hostname configuration of the API Management service. + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. + :vartype public_ip_addresses: list[str] + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service in Primary region which is deployed in an Internal Virtual Network. Available only for + Basic, Standard, Premium and Isolated SKU. + :vartype private_ip_addresses: list[str] + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :vartype public_ip_address_id: str + :ivar public_network_access: 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 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: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :ivar additional_locations: Additional datacenter locations of the API Management service. + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :ivar custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1, + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of the following ciphers by using settings + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]``: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + 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``:``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. + :vartype custom_properties: dict[str, str] + :ivar certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :vartype enable_client_certificate: bool + :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management + service. Known values are: "Enabled" and "Disabled". + :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState + :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT + Gateway deployed service. Available only for Premium SKU on stv2 platform. + :vartype outbound_public_ip_addresses: list[str] + :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple + locations. This can be used to disable the gateway in master region. + :vartype disable_gateway: bool + :ivar virtual_network_type: 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. Known values are: "None", + "External", and "Internal". + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :ivar api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + is specified and set to True all other properties will be ignored. + :vartype restore: bool + :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. + :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", "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 release_channel: Release Channel of this API Management service. Known values are: + "Preview", "Default", and "Stable". + :vartype release_channel: str or ~azure.mgmt.apimanagement.models.ReleaseChannel + :ivar zone_redundant: Zone Redundant Requirement when creating StandardV2 and PremiumV2. If + this flag is set to True, will return a APIM service with Zone redundant or fail the request if + any underneath component cannot be zone redundant. + :vartype zone_redundant: bool + """ + + notification_sender_email: Optional[str] = rest_field( + name="notificationSenderEmail", visibility=["read", "create", "update", "delete", "query"] + ) + """Email address from which the notification will be sent.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """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.""" + target_provisioning_state: Optional[str] = rest_field(name="targetProvisioningState", visibility=["read"]) + """The provisioning state of the API Management service, which is targeted by the long running + operation started on the service.""" + created_at_utc: Optional[datetime.datetime] = rest_field(name="createdAtUtc", visibility=["read"], format="rfc3339") + """Creation UTC date of the API Management service.The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + gateway_url: Optional[str] = rest_field(name="gatewayUrl", visibility=["read"]) + """Gateway URL of the API Management service.""" + gateway_regional_url: Optional[str] = rest_field(name="gatewayRegionalUrl", visibility=["read"]) + """Gateway URL of the API Management service in the Default Region.""" + portal_url: Optional[str] = rest_field(name="portalUrl", visibility=["read"]) + """Publisher portal endpoint Url of the API Management service.""" + management_api_url: Optional[str] = rest_field(name="managementApiUrl", visibility=["read"]) + """Management API endpoint URL of the API Management service.""" + scm_url: Optional[str] = rest_field(name="scmUrl", visibility=["read"]) + """SCM endpoint URL of the API Management service.""" + developer_portal_url: Optional[str] = rest_field(name="developerPortalUrl", visibility=["read"]) + """DEveloper Portal endpoint URL of the API Management service.""" + hostname_configurations: Optional[list["_models.HostnameConfiguration"]] = rest_field( + name="hostnameConfigurations", visibility=["read", "create", "update", "delete", "query"] + ) + """Custom hostname configuration of the API Management service.""" + public_ip_addresses: Optional[list[str]] = rest_field(name="publicIPAddresses", visibility=["read"]) + """Public Static Load Balanced IP addresses of the API Management service in Primary region. + Available only for Basic, Standard, Premium and Isolated SKU.""" + private_ip_addresses: Optional[list[str]] = rest_field(name="privateIPAddresses", visibility=["read"]) + """Private Static Load Balanced IP addresses of the API Management service in Primary region which + is deployed in an Internal Virtual Network. Available only for Basic, Standard, Premium and + Isolated SKU.""" + public_ip_address_id: Optional[str] = rest_field( + name="publicIpAddressId", visibility=["read", "create", "update", "delete", "query"] + ) + """Public Standard SKU IP V4 based IP address to be associated with Virtual Network deployed + service in the region. Supported only for Developer and Premium SKU being deployed in Virtual + Network.""" + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = rest_field( + name="publicNetworkAccess", visibility=["read", "create", "update", "delete", "query"] + ) + """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 + are the exclusive access method. Default value is 'Enabled'. Known values are: \"Enabled\" and + \"Disabled\".""" + configuration_api: Optional["_models.ConfigurationApi"] = rest_field( + name="configurationApi", visibility=["read", "create", "update", "delete", "query"] + ) + """Configuration API configuration of the API Management service.""" + virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = rest_field( + name="virtualNetworkConfiguration", visibility=["read", "create", "update", "delete", "query"] + ) + """Virtual network configuration of the API Management service.""" + additional_locations: Optional[list["_models.AdditionalLocation"]] = rest_field( + name="additionalLocations", visibility=["read", "create", "update", "delete", "query"] + ) + """Additional datacenter locations of the API Management service.""" + custom_properties: Optional[dict[str, str]] = rest_field( + name="customProperties", visibility=["read", "create", "update", "delete", "query"] + ) + """Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1, + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of the following ciphers by using settings + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]``: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + 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``:``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.""" + certificates: Optional[list["_models.CertificateConfiguration"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of Certificates that need to be installed in the API Management service. Max supported + certificates that can be installed is 10.""" + enable_client_certificate: Optional[bool] = rest_field( + name="enableClientCertificate", visibility=["read", "create", "update", "delete", "query"] + ) + """Property only meant to be used for Consumption SKU Service. This enforces a client certificate + to be presented on each request to the gateway. This also enables the ability to authenticate + the certificate in the policy on the gateway.""" + nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = rest_field( + name="natGatewayState", visibility=["read", "create", "update", "delete", "query"] + ) + """Property can be used to enable NAT Gateway for this API Management service. Known values are: + \"Enabled\" and \"Disabled\".""" + outbound_public_ip_addresses: Optional[list[str]] = rest_field( + name="outboundPublicIPAddresses", visibility=["read"] + ) + """Outbound public IPV4 address prefixes associated with NAT Gateway deployed service. Available + only for Premium SKU on stv2 platform.""" + disable_gateway: Optional[bool] = rest_field( + name="disableGateway", visibility=["read", "create", "update", "delete", "query"] + ) + """Property only valid for an Api Management service deployed in multiple locations. This can be + used to disable the gateway in master region.""" + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = rest_field( + name="virtualNetworkType", visibility=["read", "create", "update", "delete", "query"] + ) + """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. Known values are: \"None\", \"External\", and \"Internal\".""" + api_version_constraint: Optional["_models.ApiVersionConstraint"] = rest_field( + name="apiVersionConstraint", visibility=["read", "create", "update", "delete", "query"] + ) + """Control Plane Apis version constraint for the API Management service.""" + restore: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Undelete Api Management Service if it was previously soft-deleted. If this flag is specified + and set to True all other properties will be ignored.""" + private_endpoint_connections: Optional[list["_models.RemotePrivateEndpointConnectionWrapper"]] = rest_field( + name="privateEndpointConnections", visibility=["read", "create", "update", "delete", "query"] + ) + """List of Private Endpoint Connections of this service.""" + platform_version: Optional[Union[str, "_models.PlatformVersion"]] = rest_field( + name="platformVersion", visibility=["read"] + ) + """Compute Platform Version running the service in this location. Known values are: + \"undetermined\", \"stv1\", \"stv2\", \"mtv1\", and \"stv2.1\".""" + legacy_portal_status: Optional[Union[str, "_models.LegacyPortalStatus"]] = rest_field( + name="legacyPortalStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Status of legacy portal in the API Management service. Known values are: \"Enabled\" and + \"Disabled\".""" + developer_portal_status: Optional[Union[str, "_models.DeveloperPortalStatus"]] = rest_field( + name="developerPortalStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Status of developer portal in this API Management service. Known values are: \"Enabled\" and + \"Disabled\".""" + release_channel: Optional[Union[str, "_models.ReleaseChannel"]] = rest_field( + name="releaseChannel", visibility=["read", "create", "update", "delete", "query"] + ) + """Release Channel of this API Management service. Known values are: \"Preview\", \"Default\", and + \"Stable\".""" + zone_redundant: Optional[bool] = rest_field( + name="zoneRedundant", visibility=["read", "create", "update", "delete", "query"] + ) + """Zone Redundant Requirement when creating StandardV2 and PremiumV2. If this flag is set to True, + will return a APIM service with Zone redundant or fail the request if any underneath component + cannot be zone redundant.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + notification_sender_email: Optional[str] = None, + 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, + certificates: Optional[list["_models.CertificateConfiguration"]] = None, + enable_client_certificate: Optional[bool] = None, + nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, + disable_gateway: Optional[bool] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, + restore: Optional[bool] = None, + private_endpoint_connections: Optional[list["_models.RemotePrivateEndpointConnectionWrapper"]] = None, + legacy_portal_status: Optional[Union[str, "_models.LegacyPortalStatus"]] = None, + developer_portal_status: Optional[Union[str, "_models.DeveloperPortalStatus"]] = None, + release_channel: Optional[Union[str, "_models.ReleaseChannel"]] = None, + zone_redundant: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceCheckNameAvailabilityParameters(_Model): # pylint: disable=name-too-long + """Parameters supplied to the CheckNameAvailability operation. + + :ivar name: The name to check for availability. Required. + :vartype name: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name to check for availability. Required.""" + + @overload + def __init__( + self, + *, + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceGetDomainOwnershipIdentifierResult(_Model): # pylint: disable=name-too-long + """Response of the GetDomainOwnershipIdentifier operation. + + :ivar domain_ownership_identifier: The domain ownership identifier value. + :vartype domain_ownership_identifier: str + """ + + domain_ownership_identifier: Optional[str] = rest_field(name="domainOwnershipIdentifier", visibility=["read"]) + """The domain ownership identifier value.""" + + +class ApiManagementServiceGetSsoTokenResult(_Model): + """The response of the GetSsoToken operation. + + :ivar redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. + :vartype redirect_uri: str + """ + + redirect_uri: Optional[str] = rest_field( + name="redirectUri", visibility=["read", "create", "update", "delete", "query"] + ) + """Redirect URL to the Publisher Portal containing the SSO token.""" + + @overload + def __init__( + self, + *, + redirect_uri: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceIdentity(_Model): + """Identity properties of the Api Management service resource. + + :ivar type: The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' + includes both an implicitly created identity and a set of user assigned identities. The type + 'None' will remove any identities from the service. Required. Known values are: + "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". + :vartype type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType + :ivar principal_id: The principal id of the identity. + :vartype principal_id: str + :ivar tenant_id: The client tenant id of the identity. + :vartype tenant_id: str + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.apimanagement.models.UserIdentityProperties] + """ + + type: Union[str, "_models.ApimIdentityType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes + both an implicitly created identity and a set of user assigned identities. The type 'None' will + remove any identities from the service. Required. Known values are: \"SystemAssigned\", + \"UserAssigned\", \"SystemAssigned, UserAssigned\", and \"None\".""" + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal id of the identity.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The client tenant id of the identity.""" + user_assigned_identities: Optional[dict[str, "_models.UserIdentityProperties"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of user identities associated with the resource. The user identity dictionary key + references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ + providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.ApimIdentityType"], + user_assigned_identities: Optional[dict[str, "_models.UserIdentityProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceNameAvailabilityResult(_Model): # pylint: disable=name-too-long + """Response of the CheckNameAvailability operation. + + :ivar name_available: True if the name is available and can be used to create a new API + Management service; otherwise false. + :vartype name_available: bool + :ivar message: If reason == invalid, provide the user with the reason why the given name is + invalid, and provide the resource naming requirements so that the user can select a valid name. + If reason == AlreadyExists, explain that is already in use, and direct them to + select a different name. + :vartype message: str + :ivar reason: 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 already in use and is therefore unavailable. Known values are: "Valid", "Invalid", and + "AlreadyExists". + :vartype reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason + """ + + name_available: Optional[bool] = rest_field(name="nameAvailable", visibility=["read"]) + """True if the name is available and can be used to create a new API Management service; otherwise + false.""" + message: Optional[str] = rest_field(visibility=["read"]) + """If reason == invalid, provide the user with the reason why the given name is invalid, and + provide the resource naming requirements so that the user can select a valid name. If reason == + AlreadyExists, explain that is already in use, and direct them to select a + different name.""" + reason: Optional[Union[str, "_models.NameAvailabilityReason"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """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 + already in use and is therefore unavailable. Known values are: \"Valid\", \"Invalid\", and + \"AlreadyExists\".""" + + @overload + def __init__( + self, + *, + reason: Optional[Union[str, "_models.NameAvailabilityReason"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): + """Properties of an API Management service resource description. + + :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 + :ivar target_provisioning_state: The provisioning state of the API Management service, which is + targeted by the long running operation started on the service. + :vartype target_provisioning_state: str + :ivar created_at_utc: Creation UTC date of the API Management service.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 gateway_url: Gateway URL of the API Management service. + :vartype gateway_url: str + :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. + :vartype gateway_regional_url: str + :ivar portal_url: Publisher portal endpoint Url of the API Management service. + :vartype portal_url: str + :ivar management_api_url: Management API endpoint URL of the API Management service. + :vartype management_api_url: str + :ivar scm_url: SCM endpoint URL of the API Management service. + :vartype scm_url: str + :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. + :vartype developer_portal_url: str + :ivar hostname_configurations: Custom hostname configuration of the API Management service. + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. + :vartype public_ip_addresses: list[str] + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service in Primary region which is deployed in an Internal Virtual Network. Available only for + Basic, Standard, Premium and Isolated SKU. + :vartype private_ip_addresses: list[str] + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :vartype public_ip_address_id: str + :ivar public_network_access: 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 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: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :ivar additional_locations: Additional datacenter locations of the API Management service. + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :ivar custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1, + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of the following ciphers by using settings + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]``: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + 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``:``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. + :vartype custom_properties: dict[str, str] + :ivar certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :vartype enable_client_certificate: bool + :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management + service. Known values are: "Enabled" and "Disabled". + :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState + :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT + Gateway deployed service. Available only for Premium SKU on stv2 platform. + :vartype outbound_public_ip_addresses: list[str] + :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple + locations. This can be used to disable the gateway in master region. + :vartype disable_gateway: bool + :ivar virtual_network_type: 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. Known values are: "None", + "External", and "Internal". + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :ivar api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + is specified and set to True all other properties will be ignored. + :vartype restore: bool + :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. + :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", "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 release_channel: Release Channel of this API Management service. Known values are: + "Preview", "Default", and "Stable". + :vartype release_channel: str or ~azure.mgmt.apimanagement.models.ReleaseChannel + :ivar zone_redundant: Zone Redundant Requirement when creating StandardV2 and PremiumV2. If + this flag is set to True, will return a APIM service with Zone redundant or fail the request if + any underneath component cannot be zone redundant. + :vartype zone_redundant: bool + :ivar publisher_email: Publisher email. Required. + :vartype publisher_email: str + :ivar publisher_name: Publisher name. Required. + :vartype publisher_name: str + """ + + publisher_email: str = rest_field(name="publisherEmail", visibility=["read", "create", "update", "delete", "query"]) + """Publisher email. Required.""" + publisher_name: str = rest_field(name="publisherName", visibility=["read", "create", "update", "delete", "query"]) + """Publisher name. Required.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + publisher_email: str, + publisher_name: str, + notification_sender_email: Optional[str] = None, + 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, + certificates: Optional[list["_models.CertificateConfiguration"]] = None, + enable_client_certificate: Optional[bool] = None, + nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, + disable_gateway: Optional[bool] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, + restore: Optional[bool] = None, + private_endpoint_connections: Optional[list["_models.RemotePrivateEndpointConnectionWrapper"]] = None, + legacy_portal_status: Optional[Union[str, "_models.LegacyPortalStatus"]] = None, + developer_portal_status: Optional[Union[str, "_models.DeveloperPortalStatus"]] = None, + release_channel: Optional[Union[str, "_models.ReleaseChannel"]] = None, + zone_redundant: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceResource(TrackedResource): + """A single API Management service resource in List or Get response. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: Properties of the API Management service. Required. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiManagementServiceProperties + :ivar sku: SKU properties of the API Management service. Required. + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :ivar identity: Managed service identity of the Api Management service. + :vartype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity + :ivar etag: ETag of the resource. + :vartype etag: str + :ivar zones: The availability zones. + :vartype zones: list[str] + """ + + properties: "_models.ApiManagementServiceProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API Management service. Required.""" + sku: "_models.ApiManagementServiceSkuProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """SKU properties of the API Management service. Required.""" + identity: Optional["_models.ApiManagementServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Managed service identity of the Api Management service.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """ETag of the resource.""" + zones: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The availability zones.""" + + __flattened_items = [ + "notification_sender_email", + "provisioning_state", + "target_provisioning_state", + "created_at_utc", + "gateway_url", + "gateway_regional_url", + "portal_url", + "management_api_url", + "scm_url", + "developer_portal_url", + "hostname_configurations", + "public_ip_addresses", + "private_ip_addresses", + "public_ip_address_id", + "public_network_access", + "configuration_api", + "virtual_network_configuration", + "additional_locations", + "custom_properties", + "certificates", + "enable_client_certificate", + "nat_gateway_state", + "outbound_public_ip_addresses", + "disable_gateway", + "virtual_network_type", + "api_version_constraint", + "restore", + "private_endpoint_connections", + "platform_version", + "legacy_portal_status", + "developer_portal_status", + "release_channel", + "zone_redundant", + "publisher_email", + "publisher_name", + ] + + @overload + def __init__( + self, + *, + location: str, + properties: "_models.ApiManagementServiceProperties", + sku: "_models.ApiManagementServiceSkuProperties", + tags: Optional[dict[str, str]] = None, + identity: Optional["_models.ApiManagementServiceIdentity"] = None, + zones: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiManagementServiceSkuProperties(_Model): + """API Management service resource SKU properties. + + :ivar name: Name of the Sku. Required. Known values are: "Developer", "Standard", "Premium", + "Basic", "Consumption", "Isolated", "BasicV2", "StandardV2", and "PremiumV2". + :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. + :vartype capacity: int + """ + + name: Union[str, "_models.SkuType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the Sku. Required. Known values are: \"Developer\", \"Standard\", \"Premium\", + \"Basic\", \"Consumption\", \"Isolated\", \"BasicV2\", \"StandardV2\", and \"PremiumV2\".""" + capacity: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Capacity of the SKU (number of deployed units of the SKU). For Consumption SKU capacity must be + specified as 0. Required.""" + + @overload + def __init__( + self, + *, + name: Union[str, "_models.SkuType"], + capacity: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementServiceUpdateParameters(ApimResource): + """Parameter supplied to Update Api Management Service. + + :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 properties: Properties of the API Management service. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateProperties + :ivar sku: SKU properties of the API Management service. + :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :ivar identity: Managed service identity of the Api Management service. + :vartype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity + :ivar etag: ETag of the resource. + :vartype etag: str + :ivar zones: A list of availability zones denoting where the resource needs to come from. + :vartype zones: list[str] + """ + + properties: Optional["_models.ApiManagementServiceUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API Management service.""" + sku: Optional["_models.ApiManagementServiceSkuProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """SKU properties of the API Management service.""" + identity: Optional["_models.ApiManagementServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Managed service identity of the Api Management service.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """ETag of the resource.""" + zones: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A list of availability zones denoting where the resource needs to come from.""" + + __flattened_items = [ + "notification_sender_email", + "provisioning_state", + "target_provisioning_state", + "created_at_utc", + "gateway_url", + "gateway_regional_url", + "portal_url", + "management_api_url", + "scm_url", + "developer_portal_url", + "hostname_configurations", + "public_ip_addresses", + "private_ip_addresses", + "public_ip_address_id", + "public_network_access", + "configuration_api", + "virtual_network_configuration", + "additional_locations", + "custom_properties", + "certificates", + "enable_client_certificate", + "nat_gateway_state", + "outbound_public_ip_addresses", + "disable_gateway", + "virtual_network_type", + "api_version_constraint", + "restore", + "private_endpoint_connections", + "platform_version", + "legacy_portal_status", + "developer_portal_status", + "release_channel", + "zone_redundant", + "publisher_email", + "publisher_name", + ] + + @overload + def __init__( + self, + *, + tags: Optional[dict[str, str]] = None, + properties: Optional["_models.ApiManagementServiceUpdateProperties"] = None, + sku: Optional["_models.ApiManagementServiceSkuProperties"] = None, + identity: Optional["_models.ApiManagementServiceIdentity"] = None, + zones: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): + """Properties of an API Management service resource description. + + :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 + :ivar target_provisioning_state: The provisioning state of the API Management service, which is + targeted by the long running operation started on the service. + :vartype target_provisioning_state: str + :ivar created_at_utc: Creation UTC date of the API Management service.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 gateway_url: Gateway URL of the API Management service. + :vartype gateway_url: str + :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. + :vartype gateway_regional_url: str + :ivar portal_url: Publisher portal endpoint Url of the API Management service. + :vartype portal_url: str + :ivar management_api_url: Management API endpoint URL of the API Management service. + :vartype management_api_url: str + :ivar scm_url: SCM endpoint URL of the API Management service. + :vartype scm_url: str + :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. + :vartype developer_portal_url: str + :ivar hostname_configurations: Custom hostname configuration of the API Management service. + :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. + :vartype public_ip_addresses: list[str] + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service in Primary region which is deployed in an Internal Virtual Network. Available only for + Basic, Standard, Premium and Isolated SKU. + :vartype private_ip_addresses: list[str] + :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with + Virtual Network deployed service in the region. Supported only for Developer and Premium SKU + being deployed in Virtual Network. + :vartype public_ip_address_id: str + :ivar public_network_access: 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 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: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :ivar additional_locations: Additional datacenter locations of the API Management service. + :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :ivar custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1, + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of the following ciphers by using settings + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]``: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + 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``:``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. + :vartype custom_properties: dict[str, str] + :ivar certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :vartype enable_client_certificate: bool + :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management + service. Known values are: "Enabled" and "Disabled". + :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState + :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT + Gateway deployed service. Available only for Premium SKU on stv2 platform. + :vartype outbound_public_ip_addresses: list[str] + :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple + locations. This can be used to disable the gateway in master region. + :vartype disable_gateway: bool + :ivar virtual_network_type: 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. Known values are: "None", + "External", and "Internal". + :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :ivar api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + is specified and set to True all other properties will be ignored. + :vartype restore: bool + :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. + :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", "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 release_channel: Release Channel of this API Management service. Known values are: + "Preview", "Default", and "Stable". + :vartype release_channel: str or ~azure.mgmt.apimanagement.models.ReleaseChannel + :ivar zone_redundant: Zone Redundant Requirement when creating StandardV2 and PremiumV2. If + this flag is set to True, will return a APIM service with Zone redundant or fail the request if + any underneath component cannot be zone redundant. + :vartype zone_redundant: bool + :ivar publisher_email: Publisher email. + :vartype publisher_email: str + :ivar publisher_name: Publisher name. + :vartype publisher_name: str + """ + + publisher_email: Optional[str] = rest_field( + name="publisherEmail", visibility=["read", "create", "update", "delete", "query"] + ) + """Publisher email.""" + publisher_name: Optional[str] = rest_field( + name="publisherName", visibility=["read", "create", "update", "delete", "query"] + ) + """Publisher name.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + notification_sender_email: Optional[str] = None, + 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, + certificates: Optional[list["_models.CertificateConfiguration"]] = None, + enable_client_certificate: Optional[bool] = None, + nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, + disable_gateway: Optional[bool] = None, + virtual_network_type: Optional[Union[str, "_models.VirtualNetworkType"]] = None, + api_version_constraint: Optional["_models.ApiVersionConstraint"] = None, + restore: Optional[bool] = None, + private_endpoint_connections: Optional[list["_models.RemotePrivateEndpointConnectionWrapper"]] = None, + legacy_portal_status: Optional[Union[str, "_models.LegacyPortalStatus"]] = None, + developer_portal_status: Optional[Union[str, "_models.DeveloperPortalStatus"]] = None, + release_channel: Optional[Union[str, "_models.ReleaseChannel"]] = None, + zone_redundant: Optional[bool] = None, + publisher_email: Optional[str] = None, + publisher_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementSku(_Model): + """Describes an available ApiManagement SKU. + + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :ivar name: The name of SKU. + :vartype name: str + :ivar tier: Specifies the tier of virtual machines in a scale set.

Possible + Values:

**Standard**

**Basic**. + :vartype tier: str + :ivar size: The Size of the SKU. + :vartype size: str + :ivar family: The Family of this particular SKU. + :vartype family: str + :ivar kind: The Kind of resources that are supported in this SKU. + :vartype kind: str + :ivar capacity: Specifies the number of virtual machines in the scale set. + :vartype capacity: ~azure.mgmt.apimanagement.models.ApiManagementSkuCapacity + :ivar locations: The set of locations that the SKU is available. + :vartype locations: list[str] + :ivar location_info: A list of locations and availability zones in those locations where the + SKU is available. + :vartype location_info: list[~azure.mgmt.apimanagement.models.ApiManagementSkuLocationInfo] + :ivar api_versions: The api versions that support this SKU. + :vartype api_versions: list[str] + :ivar costs: Metadata for retrieving price info. + :vartype costs: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCosts] + :ivar capabilities: A name value pair to describe the capability. + :vartype capabilities: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities] + :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :vartype restrictions: list[~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictions] + """ + + resource_type: Optional[str] = rest_field(name="resourceType", visibility=["read"]) + """The type of resource the SKU applies to.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of SKU.""" + tier: Optional[str] = rest_field(visibility=["read"]) + """Specifies the tier of virtual machines in a scale set.

Possible Values:

+ **Standard**

**Basic**.""" + size: Optional[str] = rest_field(visibility=["read"]) + """The Size of the SKU.""" + family: Optional[str] = rest_field(visibility=["read"]) + """The Family of this particular SKU.""" + kind: Optional[str] = rest_field(visibility=["read"]) + """The Kind of resources that are supported in this SKU.""" + capacity: Optional["_models.ApiManagementSkuCapacity"] = rest_field(visibility=["read"]) + """Specifies the number of virtual machines in the scale set.""" + locations: Optional[list[str]] = rest_field(visibility=["read"]) + """The set of locations that the SKU is available.""" + location_info: Optional[list["_models.ApiManagementSkuLocationInfo"]] = rest_field( + name="locationInfo", visibility=["read"] + ) + """A list of locations and availability zones in those locations where the SKU is available.""" + api_versions: Optional[list[str]] = rest_field(name="apiVersions", visibility=["read"]) + """The api versions that support this SKU.""" + costs: Optional[list["_models.ApiManagementSkuCosts"]] = rest_field(visibility=["read"]) + """Metadata for retrieving price info.""" + capabilities: Optional[list["_models.ApiManagementSkuCapabilities"]] = rest_field(visibility=["read"]) + """A name value pair to describe the capability.""" + restrictions: Optional[list["_models.ApiManagementSkuRestrictions"]] = rest_field(visibility=["read"]) + """The restrictions because of which SKU cannot be used. This is empty if there are no + restrictions.""" + + +class ApiManagementSkuCapabilities(_Model): + """Describes The SKU capabilities object. + + :ivar name: An invariant to describe the feature. + :vartype name: str + :ivar value: An invariant if the feature is measured by quantity. + :vartype value: str + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """An invariant to describe the feature.""" + value: Optional[str] = rest_field(visibility=["read"]) + """An invariant if the feature is measured by quantity.""" + + +class ApiManagementSkuCapacity(_Model): + """Describes scaling information of a SKU. + + :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.ApiManagementSkuCapacityScaleType + """ + + minimum: Optional[int] = rest_field(visibility=["read"]) + """The minimum capacity.""" + maximum: Optional[int] = rest_field(visibility=["read"]) + """The maximum capacity that can be set.""" + default: Optional[int] = rest_field(visibility=["read"]) + """The default capacity.""" + scale_type: Optional[Union[str, "_models.ApiManagementSkuCapacityScaleType"]] = rest_field( + name="scaleType", visibility=["read"] + ) + """The scale type applicable to the sku. Known values are: \"Automatic\", \"Manual\", and + \"None\".""" + + +class ApiManagementSkuCosts(_Model): + """Describes metadata for retrieving price info. + + :ivar meter_id: Used for querying price from commerce. + :vartype meter_id: str + :ivar quantity: The multiplier is needed to extend the base metered cost. + :vartype quantity: int + :ivar extended_unit: An invariant to show the extended unit. + :vartype extended_unit: str + """ + + meter_id: Optional[str] = rest_field(name="meterID", visibility=["read"]) + """Used for querying price from commerce.""" + quantity: Optional[int] = rest_field(visibility=["read"]) + """The multiplier is needed to extend the base metered cost.""" + extended_unit: Optional[str] = rest_field(name="extendedUnit", visibility=["read"]) + """An invariant to show the extended unit.""" + + +class ApiManagementSkuLocationInfo(_Model): + """ApiManagementSkuLocationInfo. + + :ivar location: Location of the SKU. + :vartype location: str + :ivar zones: List of availability zones where the SKU is supported. + :vartype zones: list[str] + :ivar zone_details: Details of capabilities available to a SKU in specific zones. + :vartype zone_details: list[~azure.mgmt.apimanagement.models.ApiManagementSkuZoneDetails] + """ + + location: Optional[str] = rest_field(visibility=["read"]) + """Location of the SKU.""" + zones: Optional[list[str]] = rest_field(visibility=["read"]) + """List of availability zones where the SKU is supported.""" + zone_details: Optional[list["_models.ApiManagementSkuZoneDetails"]] = rest_field( + name="zoneDetails", visibility=["read"] + ) + """Details of capabilities available to a SKU in specific zones.""" + + +class ApiManagementSkuRestrictionInfo(_Model): + """ApiManagementSkuRestrictionInfo. + + :ivar locations: Locations where the SKU is restricted. + :vartype locations: list[str] + :ivar zones: List of availability zones where the SKU is restricted. + :vartype zones: list[str] + """ + + locations: Optional[list[str]] = rest_field(visibility=["read"]) + """Locations where the SKU is restricted.""" + zones: Optional[list[str]] = rest_field(visibility=["read"]) + """List of availability zones where the SKU is restricted.""" + + +class ApiManagementSkuRestrictions(_Model): + """Describes scaling information of a SKU. + + :ivar type: The type of restrictions. Known values are: "Location" and "Zone". + :vartype type: str or ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsType + :ivar values_property: The value of restrictions. If the restriction type is set to location. + This would be different locations where the SKU is restricted. + :vartype values_property: list[str] + :ivar restriction_info: The information about the restriction where the SKU cannot be used. + :vartype restriction_info: ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionInfo + :ivar reason_code: The reason for restriction. Known values are: "QuotaId" and + "NotAvailableForSubscription". + :vartype reason_code: str or + ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsReasonCode + """ + + type: Optional[Union[str, "_models.ApiManagementSkuRestrictionsType"]] = rest_field(visibility=["read"]) + """The type of restrictions. Known values are: \"Location\" and \"Zone\".""" + values_property: Optional[list[str]] = rest_field(name="values", visibility=["read"], original_tsp_name="values") + """The value of restrictions. If the restriction type is set to location. This would be different + locations where the SKU is restricted.""" + restriction_info: Optional["_models.ApiManagementSkuRestrictionInfo"] = rest_field( + name="restrictionInfo", visibility=["read"] + ) + """The information about the restriction where the SKU cannot be used.""" + reason_code: Optional[Union[str, "_models.ApiManagementSkuRestrictionsReasonCode"]] = rest_field( + name="reasonCode", visibility=["read"] + ) + """The reason for restriction. Known values are: \"QuotaId\" and \"NotAvailableForSubscription\".""" + + +class ApiManagementSkuZoneDetails(_Model): + """Describes The zonal capabilities of a SKU. + + :ivar name: The set of zones that the SKU is available in with the specified capabilities. + :vartype name: list[str] + :ivar capabilities: A list of capabilities that are available for the SKU in the specified list + of zones. + :vartype capabilities: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities] + """ + + name: Optional[list[str]] = rest_field(visibility=["read"]) + """The set of zones that the SKU is available in with the specified capabilities.""" + capabilities: Optional[list["_models.ApiManagementSkuCapabilities"]] = rest_field(visibility=["read"]) + """A list of capabilities that are available for the SKU in the specified list of zones.""" + + +class WorkspaceLinksBaseProperties(_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] + """ + + workspace_id: Optional[str] = rest_field( + name="workspaceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The link to the API Management service workspace.""" + gateways: Optional[list["_models.WorkspaceLinksGateway"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The array of linked gateways.""" + + @overload + def __init__( + self, + *, + workspace_id: Optional[str] = None, + gateways: Optional[list["_models.WorkspaceLinksGateway"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +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] + """ + + @overload + def __init__( + self, + *, + workspace_id: Optional[str] = None, + gateways: Optional[list["_models.WorkspaceLinksGateway"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiManagementWorkspaceLinksResource(ProxyResource): + """A single API Management WorkspaceLinks in List or Get response. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the API Management WorkspaceLinks. Required. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksProperties + :ivar etag: ETag of the resource. + :vartype etag: str + """ + + properties: "_models.ApiManagementWorkspaceLinksProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API Management WorkspaceLinks. Required.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """ETag of the resource.""" + + __flattened_items = ["workspace_id", "gateways"] + + @overload + def __init__( + self, + *, + properties: "_models.ApiManagementWorkspaceLinksProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiReleaseContract(ProxyResource): + """ApiRelease details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: ApiRelease entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiReleaseContractProperties + """ + + properties: Optional["_models.ApiReleaseContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """ApiRelease entity contract properties.""" + + __flattened_items = ["api_id", "created_date_time", "updated_date_time", "notes"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ApiReleaseContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiReleaseContractProperties(_Model): + """API Release details. + + :ivar api_id: Identifier of the API the release belongs to. + :vartype api_id: str + :ivar created_date_time: The time the API was released. The date conforms to the following + format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype created_date_time: ~datetime.datetime + :ivar updated_date_time: The time the API release was updated. + :vartype updated_date_time: ~datetime.datetime + :ivar notes: Release Notes. + :vartype notes: str + """ + + api_id: Optional[str] = rest_field(name="apiId", visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the API the release belongs to.""" + created_date_time: Optional[datetime.datetime] = rest_field( + name="createdDateTime", visibility=["read"], format="rfc3339" + ) + """The time the API was released. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ + as specified by the ISO 8601 standard.""" + updated_date_time: Optional[datetime.datetime] = rest_field( + name="updatedDateTime", visibility=["read"], format="rfc3339" + ) + """The time the API release was updated.""" + notes: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Release Notes.""" + + @overload + def __init__( + self, + *, + api_id: Optional[str] = None, + notes: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiRevisionContract(_Model): + """Summary of revision metadata. + + :ivar api_id: Identifier of the API Revision. + :vartype api_id: str + :ivar api_revision: Revision number of API. + :vartype api_revision: str + :ivar created_date_time: The time the API Revision was created. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype created_date_time: ~datetime.datetime + :ivar updated_date_time: The time the API Revision were updated. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype updated_date_time: ~datetime.datetime + :ivar description: Description of the API Revision. + :vartype description: str + :ivar private_url: Gateway URL for accessing the non-current API Revision. + :vartype private_url: str + :ivar is_online: Indicates if API revision is the current api revision. + :vartype is_online: bool + :ivar is_current: Indicates if API revision is accessible via the gateway. + :vartype is_current: bool + """ + + api_id: Optional[str] = rest_field(name="apiId", visibility=["read"]) + """Identifier of the API Revision.""" + api_revision: Optional[str] = rest_field(name="apiRevision", visibility=["read"]) + """Revision number of API.""" + created_date_time: Optional[datetime.datetime] = rest_field( + name="createdDateTime", visibility=["read"], format="rfc3339" + ) + """The time the API Revision was created. The date conforms to the following format: + yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard.""" + updated_date_time: Optional[datetime.datetime] = rest_field( + name="updatedDateTime", visibility=["read"], format="rfc3339" + ) + """The time the API Revision were updated. The date conforms to the following format: + yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Description of the API Revision.""" + private_url: Optional[str] = rest_field(name="privateUrl", visibility=["read"]) + """Gateway URL for accessing the non-current API Revision.""" + is_online: Optional[bool] = rest_field(name="isOnline", visibility=["read"]) + """Indicates if API revision is the current api revision.""" + is_current: Optional[bool] = rest_field(name="isCurrent", visibility=["read"]) + """Indicates if API revision is accessible via the gateway.""" + + +class ApiTagResourceContractProperties(ApiEntityBaseContract): + """API contract properties for the Tag Resources. + + :ivar description: Description of the API. May include HTML formatting tags. + :vartype description: str + :ivar authentication_settings: Collection of authentication settings included into this API. + :vartype authentication_settings: + ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :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", "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. + :vartype api_revision: str + :ivar api_version: Indicates the version identifier of the API if the API is versioned. + :vartype api_version: str + :ivar is_current: Indicates if API revision is current api revision. + :vartype is_current: bool + :ivar is_online: Indicates if API revision is accessible via the gateway. + :vartype is_online: bool + :ivar api_revision_description: Description of the API Revision. + :vartype api_revision_description: str + :ivar api_version_description: Description of the API Version. + :vartype api_version_description: str + :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. + :vartype api_version_set_id: str + :ivar subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. + :vartype subscription_required: bool + :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of + a URL. + :vartype terms_of_service_url: str + :ivar contact: Contact information for the API. + :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation + :ivar license: License information for the API. + :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation + :ivar id: API identifier in the form /apis/{apiId}. + :vartype id: str + :ivar name: API name. + :vartype name: str + :ivar service_url: Absolute URL of the backend service implementing this API. + :vartype service_url: str + :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the + API Management service instance. It is appended to the API endpoint base URL specified during + the service instance creation to form a public URL for this API. + :vartype path: str + :ivar protocols: Describes on which protocols the operations in this API can be invoked. + :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """API identifier in the form /apis/{apiId}.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """API name.""" + service_url: Optional[str] = rest_field( + name="serviceUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """Absolute URL of the backend service implementing this API.""" + path: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Relative URL uniquely identifying this API and all of its resource paths within the API + Management service instance. It is appended to the API endpoint base URL specified during the + service instance creation to form a public URL for this API.""" + protocols: Optional[list[Union[str, "_models.Protocol"]]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Describes on which protocols the operations in this API can be invoked.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "_models.ApiType"]] = None, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + terms_of_service_url: Optional[str] = None, + contact: Optional["_models.ApiContactInformation"] = None, + license: Optional["_models.ApiLicenseInformation"] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + service_url: Optional[str] = None, + path: Optional[str] = None, + protocols: Optional[list[Union[str, "_models.Protocol"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiUpdateContract(_Model): + """API update contract details. + + :ivar properties: Properties of the API entity that can be updated. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiContractUpdateProperties + """ + + properties: Optional["_models.ApiContractUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API entity that can be updated.""" + + __flattened_items = [ + "description", + "authentication_settings", + "subscription_key_parameter_names", + "api_type", + "api_revision", + "api_version", + "is_current", + "is_online", + "api_revision_description", + "api_version_description", + "api_version_set_id", + "subscription_required", + "terms_of_service_url", + "contact", + "license", + "display_name", + "service_url", + "path", + "protocols", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ApiContractUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiVersionConstraint(_Model): + """Control Plane Apis version constraint for the API Management service. + + :ivar min_api_version: Limit control plane API calls to API Management service with version + equal to or newer than this value. + :vartype min_api_version: str + """ + + min_api_version: Optional[str] = rest_field( + name="minApiVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """Limit control plane API calls to API Management service with version equal to or newer than + this value.""" + + @overload + def __init__( + self, + *, + min_api_version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiVersionSetContract(ProxyResource): + """API Version Set Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: API VersionSet contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiVersionSetContractProperties + """ + + properties: Optional["_models.ApiVersionSetContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """API VersionSet contract properties.""" + + __flattened_items = [ + "description", + "version_query_name", + "version_header_name", + "display_name", + "versioning_scheme", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ApiVersionSetContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiVersionSetContractDetails(_Model): + """An API Version Set contains the common configuration for a set of API Versions relating. + + :ivar id: Identifier for existing API Version Set. Omit this value to create a new Version Set. + :vartype id: str + :ivar name: The display Name of the API Version Set. + :vartype name: str + :ivar description: Description of API Version Set. + :vartype description: str + :ivar versioning_scheme: An value that determines where the API Version identifier will be + located in a HTTP request. Known values are: "Segment", "Query", and "Header". + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + :ivar version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :vartype version_header_name: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier for existing API Version Set. Omit this value to create a new Version Set.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The display Name of the API Version Set.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of API Version Set.""" + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = rest_field( + name="versioningScheme", visibility=["read", "create", "update", "delete", "query"] + ) + """An value that determines where the API Version identifier will be located in a HTTP request. + Known values are: \"Segment\", \"Query\", and \"Header\".""" + version_query_name: Optional[str] = rest_field( + name="versionQueryName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of query parameter that indicates the API Version if versioningScheme is set to ``query``.""" + version_header_name: Optional[str] = rest_field( + name="versionHeaderName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of HTTP header parameter that indicates the API Version if versioningScheme is set to + ``header``.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + description: Optional[str] = None, + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiVersionSetEntityBase(_Model): + """API Version set base parameters. + + :ivar description: Description of API Version Set. + :vartype description: str + :ivar version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :vartype version_header_name: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of API Version Set.""" + version_query_name: Optional[str] = rest_field( + name="versionQueryName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of query parameter that indicates the API Version if versioningScheme is set to ``query``.""" + version_header_name: Optional[str] = rest_field( + name="versionHeaderName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of HTTP header parameter that indicates the API Version if versioningScheme is set to + ``header``.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiVersionSetContractProperties(ApiVersionSetEntityBase): + """Properties of an API Version Set. + + :ivar description: Description of API Version Set. + :vartype description: str + :ivar version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :vartype version_header_name: str + :ivar display_name: Name of API Version Set. Required. + :vartype display_name: str + :ivar versioning_scheme: An value that determines where the API Version identifier will be + located in a HTTP request. Required. Known values are: "Segment", "Query", and "Header". + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Name of API Version Set. Required.""" + versioning_scheme: Union[str, "_models.VersioningScheme"] = rest_field( + name="versioningScheme", visibility=["read", "create", "update", "delete", "query"] + ) + """An value that determines where the API Version identifier will be located in a HTTP request. + Required. Known values are: \"Segment\", \"Query\", and \"Header\".""" + + @overload + def __init__( + self, + *, + display_name: str, + versioning_scheme: Union[str, "_models.VersioningScheme"], + description: Optional[str] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ApiVersionSetUpdateParameters(_Model): + """Parameters to update or create an API Version Set Contract. + + :ivar properties: Parameters to update or create an API Version Set Contract. + :vartype properties: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParametersProperties + """ + + properties: Optional["_models.ApiVersionSetUpdateParametersProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Parameters to update or create an API Version Set Contract.""" + + __flattened_items = [ + "description", + "version_query_name", + "version_header_name", + "display_name", + "versioning_scheme", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ApiVersionSetUpdateParametersProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ApiVersionSetUpdateParametersProperties(ApiVersionSetEntityBase): + """Properties used to create or update an API Version Set. + + :ivar description: Description of API Version Set. + :vartype description: str + :ivar version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :vartype version_query_name: str + :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :vartype version_header_name: str + :ivar display_name: Name of API Version Set. + :vartype display_name: str + :ivar versioning_scheme: An value that determines where the API Version identifier will be + located in a HTTP request. Known values are: "Segment", "Query", and "Header". + :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Name of API Version Set.""" + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = rest_field( + name="versioningScheme", visibility=["read", "create", "update", "delete", "query"] + ) + """An value that determines where the API Version identifier will be located in a HTTP request. + Known values are: \"Segment\", \"Query\", and \"Header\".""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + display_name: Optional[str] = None, + versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ArmIdWrapper(_Model): + """A wrapper for an ARM resource id. + + :ivar id: + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + + +class AssociationContract(ProxyResource): + """Association entity details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Association entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.AssociationContractProperties + """ + + properties: Optional["_models.AssociationContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Association entity contract properties.""" + + __flattened_items = ["provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AssociationContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AssociationContractProperties(_Model): + """Association entity contract properties. + + :ivar provisioning_state: Provisioning state. Default value is "created". + :vartype provisioning_state: str + """ + + provisioning_state: Optional[Literal["created"]] = rest_field( + name="provisioningState", visibility=["read", "create", "update", "delete", "query"] + ) + """Provisioning state. Default value is \"created\".""" + + @overload + def __init__( + self, + *, + provisioning_state: Optional[Literal["created"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthenticationSettingsContract(_Model): + """API Authentication Settings. + + :ivar o_auth2: OAuth2 Authentication settings. + :vartype o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract + :ivar openid: OpenID Connect Authentication Settings. + :vartype openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract + :ivar o_auth2_authentication_settings: Collection of OAuth2 authentication settings included + into this API. + :vartype o_auth2_authentication_settings: + list[~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract] + :ivar openid_authentication_settings: Collection of Open ID Connect authentication settings + included into this API. + :vartype openid_authentication_settings: + list[~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract] + """ + + o_auth2: Optional["_models.OAuth2AuthenticationSettingsContract"] = rest_field( + name="oAuth2", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth2 Authentication settings.""" + openid: Optional["_models.OpenIdAuthenticationSettingsContract"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """OpenID Connect Authentication Settings.""" + o_auth2_authentication_settings: Optional[list["_models.OAuth2AuthenticationSettingsContract"]] = rest_field( + name="oAuth2AuthenticationSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of OAuth2 authentication settings included into this API.""" + openid_authentication_settings: Optional[list["_models.OpenIdAuthenticationSettingsContract"]] = rest_field( + name="openidAuthenticationSettings", visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of Open ID Connect authentication settings included into this API.""" + + @overload + def __init__( + self, + *, + o_auth2: Optional["_models.OAuth2AuthenticationSettingsContract"] = None, + openid: Optional["_models.OpenIdAuthenticationSettingsContract"] = None, + o_auth2_authentication_settings: Optional[list["_models.OAuth2AuthenticationSettingsContract"]] = None, + openid_authentication_settings: Optional[list["_models.OpenIdAuthenticationSettingsContract"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationAccessPolicyContract(ProxyResource): + """Authorization access policy contract. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Authorization Contract. + :vartype properties: + ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContractProperties + """ + + properties: Optional["_models.AuthorizationAccessPolicyContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Authorization Contract.""" + + __flattened_items = ["app_ids", "tenant_id", "object_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AuthorizationAccessPolicyContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AuthorizationAccessPolicyContractProperties(_Model): # pylint: disable=name-too-long + """Authorization Access Policy details. + + :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. + :vartype object_id: str + """ + + app_ids: Optional[list[str]] = rest_field(name="appIds", visibility=["read", "create", "update", "delete", "query"]) + """The allowed Azure Active Directory Application IDs.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """The Tenant Id.""" + object_id: Optional[str] = rest_field(name="objectId", visibility=["read", "create", "update", "delete", "query"]) + """The Object Id.""" + + @overload + def __init__( + self, + *, + app_ids: Optional[list[str]] = None, + tenant_id: Optional[str] = None, + object_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationConfirmConsentCodeRequestContract(_Model): # pylint: disable=name-too-long + """Authorization confirm consent code request contract. + + :ivar consent_code: The consent code from the authorization server after authorizing and + consenting. + :vartype consent_code: str + """ + + consent_code: Optional[str] = rest_field( + name="consentCode", visibility=["read", "create", "update", "delete", "query"] + ) + """The consent code from the authorization server after authorizing and consenting.""" + + @overload + def __init__( + self, + *, + consent_code: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationContract(ProxyResource): + """Authorization contract. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Authorization Contract. + :vartype properties: ~azure.mgmt.apimanagement.models.AuthorizationContractProperties + """ + + properties: Optional["_models.AuthorizationContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Authorization Contract.""" + + __flattened_items = ["authorization_type", "o_auth2_grant_type", "parameters", "error", "status"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AuthorizationContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AuthorizationContractProperties(_Model): + """Authorization details. + + :ivar authorization_type: Authorization type options. "OAuth2" + :vartype authorization_type: str or ~azure.mgmt.apimanagement.models.AuthorizationType + :ivar o_auth2_grant_type: OAuth2 grant type options. Known values are: "AuthorizationCode" and + "ClientCredentials". + :vartype o_auth2_grant_type: str or ~azure.mgmt.apimanagement.models.OAuth2GrantType + :ivar parameters: Authorization parameters. + :vartype parameters: dict[str, str] + :ivar error: Authorization error details. + :vartype error: ~azure.mgmt.apimanagement.models.AuthorizationError + :ivar status: Status of the Authorization. + :vartype status: str + """ + + authorization_type: Optional[Union[str, "_models.AuthorizationType"]] = rest_field( + name="authorizationType", visibility=["read", "create", "update", "delete", "query"] + ) + """Authorization type options. \"OAuth2\"""" + o_auth2_grant_type: Optional[Union[str, "_models.OAuth2GrantType"]] = rest_field( + name="oauth2grantType", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth2 grant type options. Known values are: \"AuthorizationCode\" and \"ClientCredentials\".""" + parameters: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Authorization parameters.""" + error: Optional["_models.AuthorizationError"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Authorization error details.""" + status: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Status of the Authorization.""" + + @overload + def __init__( + self, + *, + authorization_type: Optional[Union[str, "_models.AuthorizationType"]] = None, + o_auth2_grant_type: Optional[Union[str, "_models.OAuth2GrantType"]] = None, + parameters: Optional[dict[str, str]] = None, + error: Optional["_models.AuthorizationError"] = None, + status: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationError(_Model): + """Authorization error details. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message. + :vartype message: str + """ + + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Error code.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Error message.""" + + @overload + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationLoginRequestContract(_Model): + """Authorization login request contract. + + :ivar post_login_redirect_url: The redirect URL after login has completed. + :vartype post_login_redirect_url: str + """ + + post_login_redirect_url: Optional[str] = rest_field( + name="postLoginRedirectUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """The redirect URL after login has completed.""" + + @overload + def __init__( + self, + *, + post_login_redirect_url: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationLoginResponseContract(_Model): + """Authorization login response contract. + + :ivar login_link: The login link. + :vartype login_link: str + """ + + login_link: Optional[str] = rest_field(name="loginLink", visibility=["read", "create", "update", "delete", "query"]) + """The login link.""" + + @overload + def __init__( + self, + *, + login_link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationProviderContract(ProxyResource): + """Authorization Provider contract. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Authorization Provider Contract. + :vartype properties: ~azure.mgmt.apimanagement.models.AuthorizationProviderContractProperties + """ + + properties: Optional["_models.AuthorizationProviderContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Authorization Provider Contract.""" + + __flattened_items = ["display_name", "identity_provider", "oauth2"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AuthorizationProviderContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AuthorizationProviderContractProperties(_Model): + """Authorization Provider details. + + :ivar display_name: Authorization Provider name. Must be 1 to 300 characters long. + :vartype display_name: str + :ivar identity_provider: Identity provider name. Must be 1 to 300 characters long. + :vartype identity_provider: str + :ivar oauth2: OAuth2 settings. + :vartype oauth2: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2Settings + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Authorization Provider name. Must be 1 to 300 characters long.""" + identity_provider: Optional[str] = rest_field( + name="identityProvider", visibility=["read", "create", "update", "delete", "query"] + ) + """Identity provider name. Must be 1 to 300 characters long.""" + oauth2: Optional["_models.AuthorizationProviderOAuth2Settings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth2 settings.""" + + @overload + def __init__( + self, + *, + display_name: Optional[str] = None, + identity_provider: Optional[str] = None, + oauth2: Optional["_models.AuthorizationProviderOAuth2Settings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationProviderKeyVaultCreateProperties(_Model): # pylint: disable=name-too-long + """Authorization Provider KeyVault create contract properties. + + :ivar secret_identifier: Key vault secret identifier for client secret. When provided, client + secret will be retrieved from the provided key vault secret. + :vartype secret_identifier: str + """ + + secret_identifier: Optional[str] = rest_field( + name="secretIdentifier", visibility=["read", "create", "update", "delete", "query"] + ) + """Key vault secret identifier for client secret. When provided, client secret will be retrieved + from the provided key vault secret.""" + + @overload + def __init__( + self, + *, + secret_identifier: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationProviderKeyVaultContract(AuthorizationProviderKeyVaultCreateProperties): + """Authorization Provider KeyVault contract properties. + + :ivar secret_identifier: Key vault secret identifier for client secret. When provided, client + secret will be retrieved from the provided key vault secret. + :vartype secret_identifier: str + :ivar updated: When the secret was last updated in key vault. + :vartype updated: ~datetime.datetime + :ivar last_status: Last time sync and refresh of secret from key vault. + :vartype last_status: + ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties + """ + + updated: Optional[datetime.datetime] = rest_field(visibility=["read"], format="rfc3339") + """When the secret was last updated in key vault.""" + last_status: Optional["_models.KeyVaultLastAccessStatusContractProperties"] = rest_field( + name="lastStatus", visibility=["read"] + ) + """Last time sync and refresh of secret from key vault.""" + + @overload + def __init__( + self, + *, + secret_identifier: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationProviderOAuth2GrantTypes(_Model): + """Authorization Provider oauth2 grant types settings. + + :ivar authorization_code: OAuth2 authorization code grant parameters. + :vartype authorization_code: dict[str, str] + :ivar client_credentials: OAuth2 client credential grant parameters. + :vartype client_credentials: dict[str, str] + """ + + authorization_code: Optional[dict[str, str]] = rest_field( + name="authorizationCode", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth2 authorization code grant parameters.""" + client_credentials: Optional[dict[str, str]] = rest_field( + name="clientCredentials", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth2 client credential grant parameters.""" + + @overload + def __init__( + self, + *, + authorization_code: Optional[dict[str, str]] = None, + client_credentials: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationProviderOAuth2Settings(_Model): + """OAuth2 settings details. + + :ivar redirect_url: Redirect URL to be set in the OAuth application. + :vartype redirect_url: str + :ivar grant_types: OAuth2 settings. + :vartype grant_types: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2GrantTypes + :ivar key_vault: Key Vault reference for client secret storage. + :vartype key_vault: ~azure.mgmt.apimanagement.models.AuthorizationProviderKeyVaultContract + """ + + redirect_url: Optional[str] = rest_field( + name="redirectUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """Redirect URL to be set in the OAuth application.""" + grant_types: Optional["_models.AuthorizationProviderOAuth2GrantTypes"] = rest_field( + name="grantTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth2 settings.""" + key_vault: Optional["_models.AuthorizationProviderKeyVaultContract"] = rest_field( + name="keyVault", visibility=["read", "create", "update", "delete", "query"] + ) + """Key Vault reference for client secret storage.""" + + @overload + def __init__( + self, + *, + redirect_url: Optional[str] = None, + grant_types: Optional["_models.AuthorizationProviderOAuth2GrantTypes"] = None, + key_vault: Optional["_models.AuthorizationProviderKeyVaultContract"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationServerContract(ProxyResource): + """External OAuth authorization server settings. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the External OAuth authorization server Contract. + :vartype properties: ~azure.mgmt.apimanagement.models.AuthorizationServerContractProperties + """ + + properties: Optional["_models.AuthorizationServerContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the External OAuth authorization server Contract.""" + + __flattened_items = [ + "description", + "authorization_methods", + "client_authentication_method", + "token_body_parameters", + "token_endpoint", + "support_state", + "default_scope", + "bearer_token_sending_methods", + "resource_owner_username", + "resource_owner_password", + "display_name", + "use_in_test_console", + "use_in_api_documentation", + "client_registration_endpoint", + "authorization_endpoint", + "grant_types", + "client_id", + "client_secret", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AuthorizationServerContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AuthorizationServerContractBaseProperties(_Model): # pylint: disable=name-too-long + """External OAuth authorization server Update settings contract. + + :ivar description: Description of the authorization server. Can contain HTML formatting tags. + :vartype description: str + :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :vartype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :ivar client_authentication_method: Method of authentication supported by the token endpoint of + this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :vartype client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :ivar token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :vartype token_endpoint: str + :ivar support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :vartype support_state: bool + :ivar default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing + space-delimited values. + :vartype default_scope: str + :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. + :vartype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :ivar resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :vartype resource_owner_username: str + :ivar resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :vartype resource_owner_password: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the authorization server. Can contain HTML formatting tags.""" + authorization_methods: Optional[list[Union[str, "_models.AuthorizationMethod"]]] = rest_field( + name="authorizationMethods", visibility=["read", "create", "update", "delete", "query"] + ) + """HTTP verbs supported by the authorization endpoint. GET must be always present. POST is + optional.""" + client_authentication_method: Optional[list[Union[str, "_models.ClientAuthenticationMethod"]]] = rest_field( + name="clientAuthenticationMethod", visibility=["read", "create", "update", "delete", "query"] + ) + """Method of authentication supported by the token endpoint of this authorization server. Possible + values are Basic and/or Body. When Body is specified, client credentials and other parameters + are passed within the request body in the application/x-www-form-urlencoded format.""" + token_body_parameters: Optional[list["_models.TokenBodyParameterContract"]] = rest_field( + name="tokenBodyParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Additional parameters required by the token endpoint of this authorization server represented + as an array of JSON objects with name and value string properties, i.e. {\"name\" : \"name + value\", \"value\": \"a value\"}.""" + token_endpoint: Optional[str] = rest_field( + name="tokenEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth token endpoint. Contains absolute URI to entity being referenced.""" + support_state: Optional[bool] = rest_field( + name="supportState", visibility=["read", "create", "update", "delete", "query"] + ) + """If true, authorization server will include state parameter from the authorization request to + its response. Client may use state parameter to raise protocol security.""" + default_scope: Optional[str] = rest_field( + name="defaultScope", visibility=["read", "create", "update", "delete", "query"] + ) + """Access token scope that is going to be requested by default. Can be overridden at the API + level. Should be provided in the form of a string containing space-delimited values.""" + bearer_token_sending_methods: Optional[list[Union[str, "_models.BearerTokenSendingMethod"]]] = rest_field( + name="bearerTokenSendingMethods", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies the mechanism by which access token is passed to the API.""" + resource_owner_username: Optional[str] = rest_field( + name="resourceOwnerUsername", visibility=["read", "create", "update", "delete", "query"] + ) + """Can be optionally specified when resource owner password grant type is supported by this + authorization server. Default resource owner username.""" + resource_owner_password: Optional[str] = rest_field( + name="resourceOwnerPassword", visibility=["read", "create", "update", "delete", "query"] + ) + """Can be optionally specified when resource owner password grant type is supported by this + authorization server. Default resource owner password.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + authorization_methods: Optional[list[Union[str, "_models.AuthorizationMethod"]]] = None, + client_authentication_method: Optional[list[Union[str, "_models.ClientAuthenticationMethod"]]] = None, + token_body_parameters: Optional[list["_models.TokenBodyParameterContract"]] = None, + token_endpoint: Optional[str] = None, + support_state: Optional[bool] = None, + default_scope: Optional[str] = None, + bearer_token_sending_methods: Optional[list[Union[str, "_models.BearerTokenSendingMethod"]]] = None, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationServerContractProperties(AuthorizationServerContractBaseProperties): + """External OAuth authorization server settings Properties. + + :ivar description: Description of the authorization server. Can contain HTML formatting tags. + :vartype description: str + :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :vartype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :ivar client_authentication_method: Method of authentication supported by the token endpoint of + this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :vartype client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :ivar token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :vartype token_endpoint: str + :ivar support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :vartype support_state: bool + :ivar default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing + space-delimited values. + :vartype default_scope: str + :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. + :vartype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :ivar resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :vartype resource_owner_username: str + :ivar resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :vartype resource_owner_password: str + :ivar display_name: User-friendly authorization server name. Required. + :vartype display_name: str + :ivar use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :vartype use_in_test_console: bool + :ivar use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :vartype use_in_api_documentation: bool + :ivar client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. Required. + :vartype client_registration_endpoint: str + :ivar authorization_endpoint: OAuth authorization endpoint. See + `http://tools.ietf.org/html/rfc6749#section-3.2 + `_. Required. + :vartype authorization_endpoint: str + :ivar grant_types: Form of an authorization grant, which the client uses to request the access + token. Required. + :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :ivar client_id: Client or app id registered with this authorization server. Required. + :vartype client_id: str + :ivar client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :vartype client_secret: str + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """User-friendly authorization server name. Required.""" + use_in_test_console: Optional[bool] = rest_field( + name="useInTestConsole", visibility=["read", "create", "update", "delete", "query"] + ) + """If true, the authorization server may be used in the developer portal test console. True by + default if no value is provided.""" + use_in_api_documentation: Optional[bool] = rest_field( + name="useInApiDocumentation", visibility=["read", "create", "update", "delete", "query"] + ) + """If true, the authorization server will be used in the API documentation in the developer + portal. False by default if no value is provided.""" + client_registration_endpoint: str = rest_field( + name="clientRegistrationEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional reference to a page where client or app registration for this authorization server is + performed. Contains absolute URL to entity being referenced. Required.""" + authorization_endpoint: str = rest_field( + name="authorizationEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth authorization endpoint. See `http://tools.ietf.org/html/rfc6749#section-3.2 + `_. Required.""" + grant_types: list[Union[str, "_models.GrantType"]] = rest_field( + name="grantTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """Form of an authorization grant, which the client uses to request the access token. Required.""" + client_id: str = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """Client or app id registered with this authorization server. Required.""" + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + """Client or app secret registered with this authorization server. This property will not be + filled on 'GET' operations! Use '/listSecrets' POST request to get the value.""" + + @overload + def __init__( + self, + *, + display_name: str, + client_registration_endpoint: str, + authorization_endpoint: str, + grant_types: list[Union[str, "_models.GrantType"]], + client_id: str, + description: Optional[str] = None, + authorization_methods: Optional[list[Union[str, "_models.AuthorizationMethod"]]] = None, + client_authentication_method: Optional[list[Union[str, "_models.ClientAuthenticationMethod"]]] = None, + token_body_parameters: Optional[list["_models.TokenBodyParameterContract"]] = None, + token_endpoint: Optional[str] = None, + support_state: Optional[bool] = None, + default_scope: Optional[str] = None, + bearer_token_sending_methods: Optional[list[Union[str, "_models.BearerTokenSendingMethod"]]] = None, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + use_in_test_console: Optional[bool] = None, + use_in_api_documentation: Optional[bool] = None, + client_secret: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationServerSecretsContract(_Model): + """OAuth Server Secrets Contract. + + :ivar client_secret: oAuth Authorization Server Secrets. + :vartype client_secret: str + :ivar resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :vartype resource_owner_username: str + :ivar resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :vartype resource_owner_password: str + """ + + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + """oAuth Authorization Server Secrets.""" + resource_owner_username: Optional[str] = rest_field( + name="resourceOwnerUsername", visibility=["read", "create", "update", "delete", "query"] + ) + """Can be optionally specified when resource owner password grant type is supported by this + authorization server. Default resource owner username.""" + resource_owner_password: Optional[str] = rest_field( + name="resourceOwnerPassword", visibility=["read", "create", "update", "delete", "query"] + ) + """Can be optionally specified when resource owner password grant type is supported by this + authorization server. Default resource owner password.""" + + @overload + def __init__( + self, + *, + client_secret: Optional[str] = None, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AuthorizationServerUpdateContract(ProxyResource): + """External OAuth authorization server settings. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the External OAuth authorization server update Contract. + :vartype properties: + ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContractProperties + """ + + properties: Optional["_models.AuthorizationServerUpdateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the External OAuth authorization server update Contract.""" + + __flattened_items = [ + "description", + "authorization_methods", + "client_authentication_method", + "token_body_parameters", + "token_endpoint", + "support_state", + "default_scope", + "bearer_token_sending_methods", + "resource_owner_username", + "resource_owner_password", + "display_name", + "use_in_test_console", + "use_in_api_documentation", + "client_registration_endpoint", + "authorization_endpoint", + "grant_types", + "client_id", + "client_secret", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.AuthorizationServerUpdateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AuthorizationServerUpdateContractProperties( + AuthorizationServerContractBaseProperties +): # pylint: disable=name-too-long + """External OAuth authorization server Update settings contract. + + :ivar description: Description of the authorization server. Can contain HTML formatting tags. + :vartype description: str + :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :vartype authorization_methods: list[str or + ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :ivar client_authentication_method: Method of authentication supported by the token endpoint of + this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :vartype client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :ivar token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :vartype token_body_parameters: + list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :vartype token_endpoint: str + :ivar support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :vartype support_state: bool + :ivar default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing + space-delimited values. + :vartype default_scope: str + :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. + :vartype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :ivar resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :vartype resource_owner_username: str + :ivar resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :vartype resource_owner_password: str + :ivar display_name: User-friendly authorization server name. + :vartype display_name: str + :ivar use_in_test_console: If true, the authorization server may be used in the developer + portal test console. True by default if no value is provided. + :vartype use_in_test_console: bool + :ivar use_in_api_documentation: If true, the authorization server will be used in the API + documentation in the developer portal. False by default if no value is provided. + :vartype use_in_api_documentation: bool + :ivar client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. + :vartype client_registration_endpoint: str + :ivar authorization_endpoint: OAuth authorization endpoint. See + `http://tools.ietf.org/html/rfc6749#section-3.2 + `_. + :vartype authorization_endpoint: str + :ivar grant_types: Form of an authorization grant, which the client uses to request the access + token. + :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :ivar client_id: Client or app id registered with this authorization server. + :vartype client_id: str + :ivar client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :vartype client_secret: str + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """User-friendly authorization server name.""" + use_in_test_console: Optional[bool] = rest_field( + name="useInTestConsole", visibility=["read", "create", "update", "delete", "query"] + ) + """If true, the authorization server may be used in the developer portal test console. True by + default if no value is provided.""" + use_in_api_documentation: Optional[bool] = rest_field( + name="useInApiDocumentation", visibility=["read", "create", "update", "delete", "query"] + ) + """If true, the authorization server will be used in the API documentation in the developer + portal. False by default if no value is provided.""" + client_registration_endpoint: Optional[str] = rest_field( + name="clientRegistrationEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional reference to a page where client or app registration for this authorization server is + performed. Contains absolute URL to entity being referenced.""" + authorization_endpoint: Optional[str] = rest_field( + name="authorizationEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth authorization endpoint. See `http://tools.ietf.org/html/rfc6749#section-3.2 + `_.""" + grant_types: Optional[list[Union[str, "_models.GrantType"]]] = rest_field( + name="grantTypes", visibility=["read", "create", "update", "delete", "query"] + ) + """Form of an authorization grant, which the client uses to request the access token.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """Client or app id registered with this authorization server.""" + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + """Client or app secret registered with this authorization server. This property will not be + filled on 'GET' operations! Use '/listSecrets' POST request to get the value.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + authorization_methods: Optional[list[Union[str, "_models.AuthorizationMethod"]]] = None, + client_authentication_method: Optional[list[Union[str, "_models.ClientAuthenticationMethod"]]] = None, + token_body_parameters: Optional[list["_models.TokenBodyParameterContract"]] = None, + token_endpoint: Optional[str] = None, + support_state: Optional[bool] = None, + default_scope: Optional[str] = None, + bearer_token_sending_methods: Optional[list[Union[str, "_models.BearerTokenSendingMethod"]]] = None, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + display_name: Optional[str] = None, + use_in_test_console: Optional[bool] = None, + use_in_api_documentation: Optional[bool] = None, + client_registration_endpoint: Optional[str] = None, + authorization_endpoint: Optional[str] = None, + grant_types: Optional[list[Union[str, "_models.GrantType"]]] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendAuthorizationHeaderCredentials(_Model): + """Authorization header information. + + :ivar scheme: Authentication Scheme name. Required. + :vartype scheme: str + :ivar parameter: Authentication Parameter value. Required. + :vartype parameter: str + """ + + scheme: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Authentication Scheme name. Required.""" + parameter: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Authentication Parameter value. Required.""" + + @overload + def __init__( + self, + *, + scheme: str, + parameter: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendBaseParameters(_Model): + """Backend entity base Parameter set. + + :ivar title: Backend Title. + :vartype title: str + :ivar description: Backend Description. + :vartype description: str + :ivar resource_id: Management Uri of the Resource in External System. This URL can be the Arm + Resource Id of Logic Apps, Function Apps or API Apps. + :vartype resource_id: str + :ivar properties: Backend Properties contract. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :ivar credentials: Backend Credentials Contract Properties. + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :ivar proxy: Backend gateway Contract Properties. + :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 azure_region: Azure region in which the backend is deployed. Can be optionally specified + to use features such as carbon-optimized load balancer. + :vartype azure_region: str + :ivar pool: Backend Pool Properties. + :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 + """ + + title: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Backend Title.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Backend Description.""" + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Management Uri of the Resource in External System. This URL can be the Arm Resource Id of Logic + Apps, Function Apps or API Apps.""" + properties: Optional["_models.BackendProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Backend Properties contract.""" + credentials: Optional["_models.BackendCredentialsContract"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Backend Credentials Contract Properties.""" + proxy: Optional["_models.BackendProxyContract"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Backend gateway Contract Properties.""" + tls: Optional["_models.BackendTlsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Backend TLS Properties.""" + circuit_breaker: Optional["_models.BackendCircuitBreaker"] = rest_field( + name="circuitBreaker", visibility=["read", "create", "update", "delete", "query"] + ) + """Backend Circuit Breaker Configuration.""" + azure_region: Optional[str] = rest_field( + name="azureRegion", visibility=["read", "create", "update", "delete", "query"] + ) + """Azure region in which the backend is deployed. Can be optionally specified to use features such + as carbon-optimized load balancer.""" + pool: Optional["_models.BackendBaseParametersPool"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Backend Pool Properties.""" + type: Optional[Union[str, "_models.BackendType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Type of the backend. A backend can be either Single or Pool. Known values are: \"Single\" and + \"Pool\".""" + + @overload + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + resource_id: Optional[str] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, + circuit_breaker: Optional["_models.BackendCircuitBreaker"] = None, + azure_region: Optional[str] = None, + pool: Optional["_models.BackendBaseParametersPool"] = None, + type: Optional[Union[str, "_models.BackendType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendPool(_Model): + """Backend pool information. + + :ivar services: The list of backend entities belonging to a pool. + :vartype services: list[~azure.mgmt.apimanagement.models.BackendPoolItem] + :ivar failure_response: The response to be returned when all the backends in the pool are + inactive. + :vartype failure_response: ~azure.mgmt.apimanagement.models.BackendFailureResponse + :ivar session_affinity: The session stickiness properties of the backend pool. + :vartype session_affinity: ~azure.mgmt.apimanagement.models.BackendSessionAffinity + """ + + services: Optional[list["_models.BackendPoolItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The list of backend entities belonging to a pool.""" + failure_response: Optional["_models.BackendFailureResponse"] = rest_field( + name="failureResponse", visibility=["read", "create", "update", "delete", "query"] + ) + """The response to be returned when all the backends in the pool are inactive.""" + session_affinity: Optional["_models.BackendSessionAffinity"] = rest_field( + name="sessionAffinity", visibility=["read", "create", "update", "delete", "query"] + ) + """The session stickiness properties of the backend pool.""" + + @overload + def __init__( + self, + *, + services: Optional[list["_models.BackendPoolItem"]] = None, + failure_response: Optional["_models.BackendFailureResponse"] = None, + session_affinity: Optional["_models.BackendSessionAffinity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendBaseParametersPool(BackendPool): + """BackendBaseParametersPool. + + :ivar services: The list of backend entities belonging to a pool. + :vartype services: list[~azure.mgmt.apimanagement.models.BackendPoolItem] + :ivar failure_response: The response to be returned when all the backends in the pool are + inactive. + :vartype failure_response: ~azure.mgmt.apimanagement.models.BackendFailureResponse + :ivar session_affinity: The session stickiness properties of the backend pool. + :vartype session_affinity: ~azure.mgmt.apimanagement.models.BackendSessionAffinity + """ + + @overload + def __init__( + self, + *, + services: Optional[list["_models.BackendPoolItem"]] = None, + failure_response: Optional["_models.BackendFailureResponse"] = None, + session_affinity: Optional["_models.BackendSessionAffinity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendCircuitBreaker(_Model): + """The configuration of the backend circuit breaker. + + :ivar rules: The rules for tripping the backend. + :vartype rules: list[~azure.mgmt.apimanagement.models.CircuitBreakerRule] + """ + + rules: Optional[list["_models.CircuitBreakerRule"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The rules for tripping the backend.""" + + @overload + def __init__( + self, + *, + rules: Optional[list["_models.CircuitBreakerRule"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendConfiguration(_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 + """ + + subnet: Optional["_models.BackendSubnetConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The default hostname of the data-plane gateway to which requests can be sent.""" + + @overload + def __init__( + self, + *, + subnet: Optional["_models.BackendSubnetConfiguration"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendContract(ProxyResource): + """Backend details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Backend entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendContractProperties + """ + + properties: Optional["_models.BackendContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Backend entity contract properties.""" + + __flattened_items = [ + "title", + "description", + "resource_id", + "properties", + "credentials", + "proxy", + "tls", + "circuit_breaker", + "azure_region", + "pool", + "type", + "url", + "protocol", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.BackendContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class BackendContractProperties(BackendBaseParameters): + """Parameters supplied to the Create Backend operation. + + :ivar title: Backend Title. + :vartype title: str + :ivar description: Backend Description. + :vartype description: str + :ivar resource_id: Management Uri of the Resource in External System. This URL can be the Arm + Resource Id of Logic Apps, Function Apps or API Apps. + :vartype resource_id: str + :ivar properties: Backend Properties contract. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :ivar credentials: Backend Credentials Contract Properties. + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :ivar proxy: Backend gateway Contract Properties. + :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 azure_region: Azure region in which the backend is deployed. Can be optionally specified + to use features such as carbon-optimized load balancer. + :vartype azure_region: str + :ivar pool: Backend Pool Properties. + :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 when backend type is 'Single'. + :vartype url: str + :ivar protocol: Backend communication protocol. Required when backend type is 'Single'. Known + values are: "http" and "soap". + :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + """ + + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Runtime Url of the Backend. Required when backend type is 'Single'.""" + protocol: Optional[Union[str, "_models.BackendProtocol"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Backend communication protocol. Required when backend type is 'Single'. Known values are: + \"http\" and \"soap\".""" + + @overload + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + resource_id: Optional[str] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, + circuit_breaker: Optional["_models.BackendCircuitBreaker"] = None, + azure_region: Optional[str] = None, + pool: Optional["_models.BackendBaseParametersPool"] = None, + type: Optional[Union[str, "_models.BackendType"]] = None, + url: Optional[str] = None, + protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendCredentialsContract(_Model): + """Details of the Credentials used to connect to Backend. + + :ivar certificate_ids: List of Client Certificate Ids. + :vartype certificate_ids: list[str] + :ivar certificate: List of Client Certificate Thumbprints. Will be ignored if certificatesIds + are provided. + :vartype certificate: list[str] + :ivar query: Query Parameter description. + :vartype query: dict[str, list[str]] + :ivar header: Header Parameter description. + :vartype header: dict[str, list[str]] + :ivar authorization: Authorization header authentication. + :vartype authorization: ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials + """ + + certificate_ids: Optional[list[str]] = rest_field( + name="certificateIds", visibility=["read", "create", "update", "delete", "query"] + ) + """List of Client Certificate Ids.""" + certificate: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of Client Certificate Thumbprints. Will be ignored if certificatesIds are provided.""" + query: Optional[dict[str, list[str]]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Query Parameter description.""" + header: Optional[dict[str, list[str]]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Header Parameter description.""" + authorization: Optional["_models.BackendAuthorizationHeaderCredentials"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Authorization header authentication.""" + + @overload + def __init__( + self, + *, + certificate_ids: Optional[list[str]] = None, + certificate: Optional[list[str]] = None, + query: Optional[dict[str, list[str]]] = None, + header: Optional[dict[str, list[str]]] = None, + authorization: Optional["_models.BackendAuthorizationHeaderCredentials"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendFailureResponse(_Model): + """The response to be returned when a backend fails to respond. + + :ivar status_code: The status code of the response. + :vartype status_code: int + """ + + status_code: Optional[int] = rest_field( + name="statusCode", visibility=["read", "create", "update", "delete", "query"] + ) + """The status code of the response.""" + + @overload + def __init__( + self, + *, + status_code: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendPoolItem(_Model): + """Backend pool service information. + + :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 + :ivar preferred_carbon_emission: Scope 2 carbon emission preference for the backend. When + specified, the load balancer will optimize traffic flow by routing to regions that have carbon + emission less than or equal to the specified category. However, when all other backends are not + available it will route traffic to these regions anyway. This requires the backend to be + attributed with 'azureRegion' information. Known values are: "VeryLow", "Low", "Medium", + "High", and "VeryHigh". + :vartype preferred_carbon_emission: str or + ~azure.mgmt.apimanagement.models.CarbonEmissionCategory + """ + + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique ARM id of the backend entity. The ARM id should refer to an already existing backend + entity. Required.""" + weight: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """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.""" + priority: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """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.""" + preferred_carbon_emission: Optional[Union[str, "_models.CarbonEmissionCategory"]] = rest_field( + name="preferredCarbonEmission", visibility=["read", "create", "update", "delete", "query"] + ) + """Scope 2 carbon emission preference for the backend. When specified, the load balancer will + optimize traffic flow by routing to regions that have carbon emission less than or equal to the + specified category. However, when all other backends are not available it will route traffic to + these regions anyway. This requires the backend to be attributed with 'azureRegion' + information. Known values are: \"VeryLow\", \"Low\", \"Medium\", \"High\", and \"VeryHigh\".""" + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + weight: Optional[int] = None, + priority: Optional[int] = None, + preferred_carbon_emission: Optional[Union[str, "_models.CarbonEmissionCategory"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendProperties(_Model): + """Properties specific to the Backend Type. + + :ivar service_fabric_cluster: Backend Service Fabric Cluster Properties. + :vartype service_fabric_cluster: + ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties + """ + + service_fabric_cluster: Optional["_models.BackendServiceFabricClusterProperties"] = rest_field( + name="serviceFabricCluster", visibility=["read", "create", "update", "delete", "query"] + ) + """Backend Service Fabric Cluster Properties.""" + + @overload + def __init__( + self, + *, + service_fabric_cluster: Optional["_models.BackendServiceFabricClusterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendProxyContract(_Model): + """Details of the Backend WebProxy Server to use in the Request to Backend. + + :ivar url: WebProxy Server AbsoluteUri property which includes the entire URI stored in the Uri + instance, including all fragments and query strings. Required. + :vartype url: str + :ivar username: Username to connect to the WebProxy server. + :vartype username: str + :ivar password: Password to connect to the WebProxy Server. + :vartype password: str + """ + + url: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """WebProxy Server AbsoluteUri property which includes the entire URI stored in the Uri instance, + including all fragments and query strings. Required.""" + username: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Username to connect to the WebProxy server.""" + password: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Password to connect to the WebProxy Server.""" + + @overload + def __init__( + self, + *, + url: str, + username: Optional[str] = None, + password: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendReconnectContract(ProxyResource): + """Reconnect request parameters. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Reconnect request properties. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendReconnectProperties + """ + + properties: Optional["_models.BackendReconnectProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Reconnect request properties.""" + + __flattened_items = ["after"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.BackendReconnectProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class BackendReconnectProperties(_Model): + """Properties to control reconnect requests. + + :ivar after: Duration in ISO8601 format after which reconnect will be initiated. Minimum + duration of the Reconnect is PT2M. + :vartype after: ~datetime.timedelta + """ + + after: Optional[datetime.timedelta] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Duration in ISO8601 format after which reconnect will be initiated. Minimum duration of the + Reconnect is PT2M.""" + + @overload + def __init__( + self, + *, + after: Optional[datetime.timedelta] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendServiceFabricClusterProperties(_Model): + """Properties of the Service Fabric Type Backend. + + :ivar client_certificate_id: The client certificate id for the management endpoint. + :vartype client_certificate_id: str + :ivar client_certificatethumbprint: The client certificate thumbprint for the management + endpoint. Will be ignored if certificatesIds are provided. + :vartype client_certificatethumbprint: str + :ivar max_partition_resolution_retries: Maximum number of retries while attempting resolve the + partition. + :vartype max_partition_resolution_retries: int + :ivar management_endpoints: The cluster management endpoint. Required. + :vartype management_endpoints: list[str] + :ivar server_certificate_thumbprints: Thumbprints of certificates cluster management service + uses for tls communication. + :vartype server_certificate_thumbprints: list[str] + :ivar server_x509_names: Server X509 Certificate Names Collection. + :vartype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] + """ + + client_certificate_id: Optional[str] = rest_field( + name="clientCertificateId", visibility=["read", "create", "update", "delete", "query"] + ) + """The client certificate id for the management endpoint.""" + client_certificatethumbprint: Optional[str] = rest_field( + name="clientCertificatethumbprint", visibility=["read", "create", "update", "delete", "query"] + ) + """The client certificate thumbprint for the management endpoint. Will be ignored if + certificatesIds are provided.""" + max_partition_resolution_retries: Optional[int] = rest_field( + name="maxPartitionResolutionRetries", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum number of retries while attempting resolve the partition.""" + management_endpoints: list[str] = rest_field( + name="managementEndpoints", visibility=["read", "create", "update", "delete", "query"] + ) + """The cluster management endpoint. Required.""" + server_certificate_thumbprints: Optional[list[str]] = rest_field( + name="serverCertificateThumbprints", visibility=["read", "create", "update", "delete", "query"] + ) + """Thumbprints of certificates cluster management service uses for tls communication.""" + server_x509_names: Optional[list["_models.X509CertificateName"]] = rest_field( + name="serverX509Names", visibility=["read", "create", "update", "delete", "query"] + ) + """Server X509 Certificate Names Collection.""" + + @overload + def __init__( + self, + *, + management_endpoints: list[str], + client_certificate_id: Optional[str] = None, + client_certificatethumbprint: Optional[str] = None, + max_partition_resolution_retries: Optional[int] = None, + server_certificate_thumbprints: Optional[list[str]] = None, + server_x509_names: Optional[list["_models.X509CertificateName"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendSessionAffinity(_Model): + """The session stickiness properties of the backend pool. + + :ivar session_id: The id that identifies the requests belonging to the same session. + :vartype session_id: ~azure.mgmt.apimanagement.models.BackendSessionId + """ + + session_id: Optional["_models.BackendSessionId"] = rest_field( + name="sessionId", visibility=["read", "create", "update", "delete", "query"] + ) + """The id that identifies the requests belonging to the same session.""" + + @overload + def __init__( + self, + *, + session_id: Optional["_models.BackendSessionId"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendSessionId(_Model): + """The properties of the id that identifies the requests belonging to the same session. + + :ivar source: Source from where the session id is extracted. "cookie" + :vartype source: str or ~azure.mgmt.apimanagement.models.BackendSessionIdSource + :ivar name: Name of the variable that refers to the session id. + :vartype name: str + """ + + source: Optional[Union[str, "_models.BackendSessionIdSource"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Source from where the session id is extracted. \"cookie\"""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the variable that refers to the session id.""" + + @overload + def __init__( + self, + *, + source: Optional[Union[str, "_models.BackendSessionIdSource"]] = None, + name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendSubnetConfiguration(_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 + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ARM ID of the subnet in which the backend systems are hosted.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendTlsProperties(_Model): + """Properties controlling TLS Certificate Validation. + + :ivar validate_certificate_chain: Flag indicating whether SSL certificate chain validation + should be done when using self-signed certificates for this backend host. + :vartype validate_certificate_chain: bool + :ivar validate_certificate_name: Flag indicating whether SSL certificate name validation should + be done when using self-signed certificates for this backend host. + :vartype validate_certificate_name: bool + :ivar server_certificate_thumbprints: Thumbprints of certificates used by the backend host for + TLS communication. + :vartype server_certificate_thumbprints: list[str] + :ivar server_x509_names: Server X509 Certificate Names of the Backend Host. + :vartype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] + """ + + validate_certificate_chain: Optional[bool] = rest_field( + name="validateCertificateChain", visibility=["read", "create", "update", "delete", "query"] + ) + """Flag indicating whether SSL certificate chain validation should be done when using self-signed + certificates for this backend host.""" + validate_certificate_name: Optional[bool] = rest_field( + name="validateCertificateName", visibility=["read", "create", "update", "delete", "query"] + ) + """Flag indicating whether SSL certificate name validation should be done when using self-signed + certificates for this backend host.""" + server_certificate_thumbprints: Optional[list[str]] = rest_field( + name="serverCertificateThumbprints", visibility=["read", "create", "update", "delete", "query"] + ) + """Thumbprints of certificates used by the backend host for TLS communication.""" + server_x509_names: Optional[list["_models.X509CertificateName"]] = rest_field( + name="serverX509Names", visibility=["read", "create", "update", "delete", "query"] + ) + """Server X509 Certificate Names of the Backend Host.""" + + @overload + def __init__( + self, + *, + validate_certificate_chain: Optional[bool] = None, + validate_certificate_name: Optional[bool] = None, + server_certificate_thumbprints: Optional[list[str]] = None, + server_x509_names: Optional[list["_models.X509CertificateName"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendUpdateParameterProperties(BackendBaseParameters): + """Parameters supplied to the Update Backend operation. + + :ivar title: Backend Title. + :vartype title: str + :ivar description: Backend Description. + :vartype description: str + :ivar resource_id: Management Uri of the Resource in External System. This URL can be the Arm + Resource Id of Logic Apps, Function Apps or API Apps. + :vartype resource_id: str + :ivar properties: Backend Properties contract. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties + :ivar credentials: Backend Credentials Contract Properties. + :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :ivar proxy: Backend gateway Contract Properties. + :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 azure_region: Azure region in which the backend is deployed. Can be optionally specified + to use features such as carbon-optimized load balancer. + :vartype azure_region: str + :ivar pool: Backend Pool Properties. + :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". + :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + """ + + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Runtime Url of the Backend.""" + protocol: Optional[Union[str, "_models.BackendProtocol"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Backend communication protocol. Known values are: \"http\" and \"soap\".""" + + @overload + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + resource_id: Optional[str] = None, + properties: Optional["_models.BackendProperties"] = None, + credentials: Optional["_models.BackendCredentialsContract"] = None, + proxy: Optional["_models.BackendProxyContract"] = None, + tls: Optional["_models.BackendTlsProperties"] = None, + circuit_breaker: Optional["_models.BackendCircuitBreaker"] = None, + azure_region: Optional[str] = None, + pool: Optional["_models.BackendBaseParametersPool"] = None, + type: Optional[Union[str, "_models.BackendType"]] = None, + url: Optional[str] = None, + protocol: Optional[Union[str, "_models.BackendProtocol"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class BackendUpdateParameters(_Model): + """Backend update parameters. + + :ivar properties: Backend entity update contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.BackendUpdateParameterProperties + """ + + properties: Optional["_models.BackendUpdateParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Backend entity update contract properties.""" + + __flattened_items = [ + "title", + "description", + "resource_id", + "properties", + "credentials", + "proxy", + "tls", + "circuit_breaker", + "azure_region", + "pool", + "type", + "url", + "protocol", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.BackendUpdateParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class BodyDiagnosticSettings(_Model): + """Body logging settings. + + :ivar bytes: Number of request body bytes to log. + :vartype bytes: int + """ + + bytes: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Number of request body bytes to log.""" + + @overload + def __init__( + self, + *, + bytes: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CacheContract(ProxyResource): + """Cache details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Cache properties details. + :vartype properties: ~azure.mgmt.apimanagement.models.CacheContractProperties + """ + + properties: Optional["_models.CacheContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Cache properties details.""" + + __flattened_items = ["description", "connection_string", "use_from_location", "resource_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CacheContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CacheContractProperties(_Model): + """Properties of the Cache contract. + + :ivar description: Cache description. + :vartype description: str + :ivar connection_string: Runtime connection string to cache. Required. + :vartype connection_string: str + :ivar use_from_location: Location identifier to use cache from (should be either 'default' or + valid Azure region identifier). Required. + :vartype use_from_location: str + :ivar resource_id: Original uri of entity in external system cache points to. + :vartype resource_id: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Cache description.""" + connection_string: str = rest_field( + name="connectionString", visibility=["read", "create", "update", "delete", "query"] + ) + """Runtime connection string to cache. Required.""" + use_from_location: str = rest_field( + name="useFromLocation", visibility=["read", "create", "update", "delete", "query"] + ) + """Location identifier to use cache from (should be either 'default' or valid Azure region + identifier). Required.""" + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Original uri of entity in external system cache points to.""" + + @overload + def __init__( + self, + *, + connection_string: str, + use_from_location: str, + description: Optional[str] = None, + resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CacheUpdateParameters(_Model): + """Cache update details. + + :ivar properties: Cache update properties details. + :vartype properties: ~azure.mgmt.apimanagement.models.CacheUpdateProperties + """ + + properties: Optional["_models.CacheUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Cache update properties details.""" + + __flattened_items = ["description", "connection_string", "use_from_location", "resource_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CacheUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CacheUpdateProperties(_Model): + """Parameters supplied to the Update Cache operation. + + :ivar description: Cache description. + :vartype description: str + :ivar connection_string: Runtime connection string to cache. + :vartype connection_string: str + :ivar use_from_location: Location identifier to use cache from (should be either 'default' or + valid Azure region identifier). + :vartype use_from_location: str + :ivar resource_id: Original uri of entity in external system cache points to. + :vartype resource_id: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Cache description.""" + connection_string: Optional[str] = rest_field( + name="connectionString", visibility=["read", "create", "update", "delete", "query"] + ) + """Runtime connection string to cache.""" + use_from_location: Optional[str] = rest_field( + name="useFromLocation", visibility=["read", "create", "update", "delete", "query"] + ) + """Location identifier to use cache from (should be either 'default' or valid Azure region + identifier).""" + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Original uri of entity in external system cache points to.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + connection_string: Optional[str] = None, + use_from_location: Optional[str] = None, + resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CertificateConfiguration(_Model): + """Certificate configuration which consist of non-trusted intermediates and root certificates. + + :ivar encoded_certificate: Base64 Encoded certificate. + :vartype encoded_certificate: str + :ivar certificate_password: Certificate Password. + :vartype certificate_password: str + :ivar store_name: The System.Security.Cryptography.x509certificates.StoreName certificate store + location. Only Root and CertificateAuthority are valid locations. Required. Known values are: + "CertificateAuthority" and "Root". + :vartype store_name: str or ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName + :ivar certificate: Certificate information. + :vartype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation + """ + + encoded_certificate: Optional[str] = rest_field( + name="encodedCertificate", visibility=["read", "create", "update", "delete", "query"] + ) + """Base64 Encoded certificate.""" + certificate_password: Optional[str] = rest_field( + name="certificatePassword", visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate Password.""" + store_name: Union[str, "_models.CertificateConfigurationStoreName"] = rest_field( + name="storeName", visibility=["read", "create", "update", "delete", "query"] + ) + """The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only + Root and CertificateAuthority are valid locations. Required. Known values are: + \"CertificateAuthority\" and \"Root\".""" + certificate: Optional["_models.CertificateInformation"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate information.""" + + @overload + def __init__( + self, + *, + store_name: Union[str, "_models.CertificateConfigurationStoreName"], + encoded_certificate: Optional[str] = None, + certificate_password: Optional[str] = None, + certificate: Optional["_models.CertificateInformation"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CertificateContract(ProxyResource): + """Certificate details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Certificate properties details. + :vartype properties: ~azure.mgmt.apimanagement.models.CertificateContractProperties + """ + + properties: Optional["_models.CertificateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate properties details.""" + + __flattened_items = ["subject", "thumbprint", "expiration_date", "key_vault"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CertificateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CertificateContractProperties(_Model): + """Properties of the Certificate contract. + + :ivar subject: Subject attribute of the certificate. Required. + :vartype subject: str + :ivar thumbprint: Thumbprint of the certificate. Required. + :vartype thumbprint: str + :ivar expiration_date: Expiration date of the certificate. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. + :vartype expiration_date: ~datetime.datetime + :ivar key_vault: KeyVault location details of the certificate. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + """ + + subject: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Subject attribute of the certificate. Required.""" + thumbprint: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Thumbprint of the certificate. Required.""" + expiration_date: datetime.datetime = rest_field( + name="expirationDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Expiration date of the certificate. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required.""" + key_vault: Optional["_models.KeyVaultContractProperties"] = rest_field( + name="keyVault", visibility=["read", "create", "update", "delete", "query"] + ) + """KeyVault location details of the certificate.""" + + @overload + def __init__( + self, + *, + subject: str, + thumbprint: str, + expiration_date: datetime.datetime, + key_vault: Optional["_models.KeyVaultContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CertificateCreateOrUpdateParameters(_Model): + """Certificate create or update details. + + :ivar properties: Certificate create or update properties details. + :vartype properties: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateProperties + """ + + properties: Optional["_models.CertificateCreateOrUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate create or update properties details.""" + + __flattened_items = ["data", "password", "key_vault"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.CertificateCreateOrUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class CertificateCreateOrUpdateProperties(_Model): + """Parameters supplied to the CreateOrUpdate certificate operation. + + :ivar data: Base 64 encoded certificate using the application/x-pkcs12 representation. + :vartype data: str + :ivar password: Password for the Certificate. + :vartype password: str + :ivar key_vault: KeyVault location details of the certificate. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + """ + + data: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Base 64 encoded certificate using the application/x-pkcs12 representation.""" + password: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Password for the Certificate.""" + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = rest_field( + name="keyVault", visibility=["read", "create", "update", "delete", "query"] + ) + """KeyVault location details of the certificate.""" + + @overload + def __init__( + self, + *, + data: Optional[str] = None, + password: Optional[str] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CertificateInformation(_Model): + """SSL certificate information. + + :ivar expiry: Expiration date of the certificate. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. + :vartype expiry: ~datetime.datetime + :ivar thumbprint: Thumbprint of the certificate. Required. + :vartype thumbprint: str + :ivar subject: Subject of the certificate. Required. + :vartype subject: str + """ + + expiry: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc3339") + """Expiration date of the certificate. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required.""" + thumbprint: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Thumbprint of the certificate. Required.""" + subject: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Subject of the certificate. Required.""" + + @overload + def __init__( + self, + *, + expiry: datetime.datetime, + thumbprint: str, + subject: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CircuitBreakerFailureCondition(_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] + """ + + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The threshold for opening the circuit.""" + percentage: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The threshold for opening the circuit.""" + interval: Optional[datetime.timedelta] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The interval during which the failures are counted.""" + status_code_ranges: Optional[list["_models.FailureStatusCodeRange"]] = rest_field( + name="statusCodeRanges", visibility=["read", "create", "update", "delete", "query"] + ) + """The status code ranges which are considered as failure.""" + error_reasons: Optional[list[str]] = rest_field( + name="errorReasons", visibility=["read", "create", "update", "delete", "query"] + ) + """The error reasons which are considered as failure.""" + + @overload + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CircuitBreakerRule(_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 + :ivar failure_response: The response of the backend when the circuit breaker gets open. + :vartype failure_response: ~azure.mgmt.apimanagement.models.BackendFailureResponse + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The rule name.""" + failure_condition: Optional["_models.CircuitBreakerFailureCondition"] = rest_field( + name="failureCondition", visibility=["read", "create", "update", "delete", "query"] + ) + """The conditions for tripping the circuit breaker.""" + trip_duration: Optional[datetime.timedelta] = rest_field( + name="tripDuration", visibility=["read", "create", "update", "delete", "query"] + ) + """The duration for which the circuit will be tripped.""" + accept_retry_after: Optional[bool] = rest_field( + name="acceptRetryAfter", visibility=["read", "create", "update", "delete", "query"] + ) + """flag to accept Retry-After header from the backend.""" + failure_response: Optional["_models.BackendFailureResponse"] = rest_field( + name="failureResponse", visibility=["read", "create", "update", "delete", "query"] + ) + """The response of the backend when the circuit breaker gets open.""" + + @overload + 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, + failure_response: Optional["_models.BackendFailureResponse"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ClientApplicationContract(ProxyResource): + """Client application details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Client application entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.ClientApplicationContractProperties + """ + + properties: Optional["_models.ClientApplicationContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Client application entity contract properties.""" + + __flattened_items = ["display_name", "description", "owner_id", "entra_application_id", "entra_tenant_id", "state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ClientApplicationContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ClientApplicationContractProperties(_Model): + """Client Application Entity Properties. + + :ivar display_name: Client application name. Required. + :vartype display_name: str + :ivar description: Client application description. + :vartype description: str + :ivar owner_id: A resource identifier for the user who owns the application. Required. + :vartype owner_id: str + :ivar entra_application_id: Microsoft EntraID Application ID (Client ID). This is the value + that is used to identify the application when it is requesting access tokens from Microsoft + EntraID. This property is read-only and will be set by the system when the application is + created. + :vartype entra_application_id: str + :ivar entra_tenant_id: Tenant ID is a unique identifier (a GUID) for an organization directory + in Microsoft’s cloud. It’s used to identify tenants across Microsoft services. + :vartype entra_tenant_id: str + :ivar state: Client application state. The value derives the state of an application based on + the statuses of its associated ClientApplicationProductLinks. Known values are: "pending", + "active", "rejected", and "approved". + :vartype state: str or ~azure.mgmt.apimanagement.models.ClientApplicationState + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Client application name. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Client application description.""" + owner_id: str = rest_field(name="ownerId", visibility=["read", "create", "update", "delete", "query"]) + """A resource identifier for the user who owns the application. Required.""" + entra_application_id: Optional[str] = rest_field(name="entraApplicationId", visibility=["read"]) + """Microsoft EntraID Application ID (Client ID). This is the value that is used to identify the + application when it is requesting access tokens from Microsoft EntraID. This property is + read-only and will be set by the system when the application is created.""" + entra_tenant_id: Optional[str] = rest_field(name="entraTenantId", visibility=["read"]) + """Tenant ID is a unique identifier (a GUID) for an organization directory in Microsoft’s cloud. + It’s used to identify tenants across Microsoft services.""" + state: Optional[Union[str, "_models.ClientApplicationState"]] = rest_field(visibility=["read"]) + """Client application state. The value derives the state of an application based on the statuses + of its associated ClientApplicationProductLinks. Known values are: \"pending\", \"active\", + \"rejected\", and \"approved\".""" + + @overload + def __init__( + self, + *, + display_name: str, + owner_id: str, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ClientApplicationProductLinkContract(ProxyResource): + """Specifies Client Application - Product link assignment. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Client application - product link entity contract properties. + :vartype properties: + ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContractProperties + """ + + properties: Optional["_models.ClientApplicationProductLinkContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Client application - product link entity contract properties.""" + + __flattened_items = ["product_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ClientApplicationProductLinkContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ClientApplicationProductLinkContractProperties(_Model): # pylint: disable=name-too-long + """ClientApplicationProductLinkContractProperties. + + :ivar product_id: The unique resource identifier of the Product. Required. + :vartype product_id: str + """ + + product_id: str = rest_field(name="productId", visibility=["read", "create", "update", "delete", "query"]) + """The unique resource identifier of the Product. Required.""" + + @overload + def __init__( + self, + *, + product_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ClientApplicationSecretsContract(_Model): + """Specifies client application secrets needed to authorize applications API calls. + + :ivar entra: Microsoft EntraID client application secrets. + :vartype entra: ~azure.mgmt.apimanagement.models.ClientApplicationSecretsContractEntra + """ + + entra: Optional["_models.ClientApplicationSecretsContractEntra"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Microsoft EntraID client application secrets.""" + + @overload + def __init__( + self, + *, + entra: Optional["_models.ClientApplicationSecretsContractEntra"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ClientApplicationSecretsContractEntra(_Model): + """Microsoft EntraID client application secrets. + + :ivar client_secret: EntraID client application secret. + :vartype client_secret: str + :ivar expires_at: EntraID client application secret expiration date. + :vartype expires_at: ~datetime.datetime + """ + + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + """EntraID client application secret.""" + expires_at: Optional[datetime.datetime] = rest_field(name="expiresAt", visibility=["read"], format="rfc3339") + """EntraID client application secret expiration date.""" + + @overload + def __init__( + self, + *, + client_secret: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ClientSecretContract(_Model): + """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + + :ivar client_secret: Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + :vartype client_secret: str + """ + + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth.""" + + @overload + def __init__( + self, + *, + client_secret: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConfigurationApi(_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 + """ + + legacy_api: Optional[Union[str, "_models.LegacyApiState"]] = rest_field( + name="legacyApi", visibility=["read", "create", "update", "delete", "query"] + ) + """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\".""" + + @overload + def __init__( + self, + *, + legacy_api: Optional[Union[str, "_models.LegacyApiState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectivityCheckRequest(_Model): + """A request to perform the connectivity check operation on a API Management service. + + :ivar source: Definitions about the connectivity check origin. Required. + :vartype source: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestSource + :ivar destination: The connectivity check operation destination. Required. + :vartype destination: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestDestination + :ivar preferred_ip_version: The IP version to be used. Only IPv4 is supported for now. "IPv4" + :vartype preferred_ip_version: str or ~azure.mgmt.apimanagement.models.PreferredIPVersion + :ivar protocol: The request's protocol. Specific protocol configuration can be available based + on this selection. The specified destination address must be coherent with this value. Known + values are: "TCP", "HTTP", and "HTTPS". + :vartype protocol: str or ~azure.mgmt.apimanagement.models.ConnectivityCheckProtocol + :ivar protocol_configuration: Protocol-specific configuration. + :vartype protocol_configuration: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration + """ + + source: "_models.ConnectivityCheckRequestSource" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Definitions about the connectivity check origin. Required.""" + destination: "_models.ConnectivityCheckRequestDestination" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The connectivity check operation destination. Required.""" + preferred_ip_version: Optional[Union[str, "_models.PreferredIPVersion"]] = rest_field( + name="preferredIPVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """The IP version to be used. Only IPv4 is supported for now. \"IPv4\"""" + protocol: Optional[Union[str, "_models.ConnectivityCheckProtocol"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The request's protocol. Specific protocol configuration can be available based on this + selection. The specified destination address must be coherent with this value. Known values + are: \"TCP\", \"HTTP\", and \"HTTPS\".""" + protocol_configuration: Optional["_models.ConnectivityCheckRequestProtocolConfiguration"] = rest_field( + name="protocolConfiguration", visibility=["read", "create", "update", "delete", "query"] + ) + """Protocol-specific configuration.""" + + @overload + def __init__( + self, + *, + source: "_models.ConnectivityCheckRequestSource", + destination: "_models.ConnectivityCheckRequestDestination", + preferred_ip_version: Optional[Union[str, "_models.PreferredIPVersion"]] = None, + protocol: Optional[Union[str, "_models.ConnectivityCheckProtocol"]] = None, + protocol_configuration: Optional["_models.ConnectivityCheckRequestProtocolConfiguration"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectivityCheckRequestDestination(_Model): + """The connectivity check operation destination. + + :ivar address: Destination address. Can either be an IP address or a FQDN. Required. + :vartype address: str + :ivar port: Destination port. Required. + :vartype port: int + """ + + address: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Destination address. Can either be an IP address or a FQDN. Required.""" + port: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Destination port. Required.""" + + @overload + def __init__( + self, + *, + address: str, + port: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectivityCheckRequestProtocolConfiguration(_Model): # pylint: disable=name-too-long + """Protocol-specific configuration. + + :ivar http_configuration: Configuration for HTTP or HTTPS requests. + :vartype http_configuration: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration + """ + + http_configuration: Optional["_models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration"] = rest_field( + name="HTTPConfiguration", visibility=["read", "create", "update", "delete", "query"] + ) + """Configuration for HTTP or HTTPS requests.""" + + @overload + def __init__( + self, + *, + http_configuration: Optional["_models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration(_Model): # pylint: disable=name-too-long + """Configuration for HTTP or HTTPS requests. + + :ivar method: The HTTP method to be used. Known values are: "GET" and "POST". + :vartype method: str or ~azure.mgmt.apimanagement.models.Method + :ivar valid_status_codes: List of HTTP status codes considered valid for the request response. + :vartype valid_status_codes: list[int] + :ivar headers: List of headers to be included in the request. + :vartype headers: list[~azure.mgmt.apimanagement.models.HTTPHeader] + """ + + method: Optional[Union[str, "_models.Method"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The HTTP method to be used. Known values are: \"GET\" and \"POST\".""" + valid_status_codes: Optional[list[int]] = rest_field( + name="validStatusCodes", visibility=["read", "create", "update", "delete", "query"] + ) + """List of HTTP status codes considered valid for the request response.""" + headers: Optional[list["_models.HTTPHeader"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """List of headers to be included in the request.""" + + @overload + def __init__( + self, + *, + method: Optional[Union[str, "_models.Method"]] = None, + valid_status_codes: Optional[list[int]] = None, + headers: Optional[list["_models.HTTPHeader"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectivityCheckRequestSource(_Model): + """Definitions about the connectivity check origin. + + :ivar region: The API Management service region from where to start the connectivity check + operation. Required. + :vartype region: str + :ivar instance: The particular VMSS instance from which to fire the request. + :vartype instance: int + """ + + region: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The API Management service region from where to start the connectivity check operation. + Required.""" + instance: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The particular VMSS instance from which to fire the request.""" + + @overload + def __init__( + self, + *, + region: str, + instance: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ConnectivityCheckResponse(_Model): + """Information on the connectivity status. + + :ivar hops: List of hops between the source and the destination. + :vartype hops: list[~azure.mgmt.apimanagement.models.ConnectivityHop] + :ivar connection_status: The connection status. Known values are: "Unknown", "Connected", + "Disconnected", and "Degraded". + :vartype connection_status: str or ~azure.mgmt.apimanagement.models.ConnectionStatus + :ivar avg_latency_in_ms: Average latency in milliseconds. + :vartype avg_latency_in_ms: int + :ivar min_latency_in_ms: Minimum latency in milliseconds. + :vartype min_latency_in_ms: int + :ivar max_latency_in_ms: Maximum latency in milliseconds. + :vartype max_latency_in_ms: int + :ivar probes_sent: Total number of probes sent. + :vartype probes_sent: int + :ivar probes_failed: Number of failed probes. + :vartype probes_failed: int + """ + + hops: Optional[list["_models.ConnectivityHop"]] = rest_field(visibility=["read"]) + """List of hops between the source and the destination.""" + connection_status: Optional[Union[str, "_models.ConnectionStatus"]] = rest_field( + name="connectionStatus", visibility=["read"] + ) + """The connection status. Known values are: \"Unknown\", \"Connected\", \"Disconnected\", and + \"Degraded\".""" + avg_latency_in_ms: Optional[int] = rest_field(name="avgLatencyInMs", visibility=["read"]) + """Average latency in milliseconds.""" + min_latency_in_ms: Optional[int] = rest_field(name="minLatencyInMs", visibility=["read"]) + """Minimum latency in milliseconds.""" + max_latency_in_ms: Optional[int] = rest_field(name="maxLatencyInMs", visibility=["read"]) + """Maximum latency in milliseconds.""" + probes_sent: Optional[int] = rest_field(name="probesSent", visibility=["read"]) + """Total number of probes sent.""" + probes_failed: Optional[int] = rest_field(name="probesFailed", visibility=["read"]) + """Number of failed probes.""" + + +class ConnectivityHop(_Model): + """Information about a hop between the source and the destination. + + :ivar type: The type of the hop. + :vartype type: str + :ivar id: The ID of the hop. + :vartype id: str + :ivar address: The IP address of the hop. + :vartype address: str + :ivar resource_id: The ID of the resource corresponding to this hop. + :vartype resource_id: str + :ivar next_hop_ids: List of next hop identifiers. + :vartype next_hop_ids: list[str] + :ivar issues: List of issues. + :vartype issues: list[~azure.mgmt.apimanagement.models.ConnectivityIssue] + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the hop.""" + id: Optional[str] = rest_field(visibility=["read"]) + """The ID of the hop.""" + address: Optional[str] = rest_field(visibility=["read"]) + """The IP address of the hop.""" + resource_id: Optional[str] = rest_field(name="resourceId", visibility=["read"]) + """The ID of the resource corresponding to this hop.""" + next_hop_ids: Optional[list[str]] = rest_field(name="nextHopIds", visibility=["read"]) + """List of next hop identifiers.""" + issues: Optional[list["_models.ConnectivityIssue"]] = rest_field(visibility=["read"]) + """List of issues.""" + + +class ConnectivityIssue(_Model): + """Information about an issue encountered in the process of checking for connectivity. + + :ivar origin: The origin of the issue. Known values are: "Local", "Inbound", and "Outbound". + :vartype origin: str or ~azure.mgmt.apimanagement.models.Origin + :ivar severity: The severity of the issue. Known values are: "Error" and "Warning". + :vartype severity: str or ~azure.mgmt.apimanagement.models.Severity + :ivar type: The type of issue. Known values are: "Unknown", "AgentStopped", "GuestFirewall", + "DnsResolution", "SocketBind", "NetworkSecurityRule", "UserDefinedRoute", "PortThrottled", and + "Platform". + :vartype type: str or ~azure.mgmt.apimanagement.models.IssueType + :ivar context: Provides additional context on the issue. + :vartype context: list[dict[str, str]] + """ + + origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) + """The origin of the issue. Known values are: \"Local\", \"Inbound\", and \"Outbound\".""" + severity: Optional[Union[str, "_models.Severity"]] = rest_field(visibility=["read"]) + """The severity of the issue. Known values are: \"Error\" and \"Warning\".""" + type: Optional[Union[str, "_models.IssueType"]] = rest_field(visibility=["read"]) + """The type of issue. Known values are: \"Unknown\", \"AgentStopped\", \"GuestFirewall\", + \"DnsResolution\", \"SocketBind\", \"NetworkSecurityRule\", \"UserDefinedRoute\", + \"PortThrottled\", and \"Platform\".""" + context: Optional[list[dict[str, str]]] = rest_field(visibility=["read"]) + """Provides additional context on the issue.""" + + +class ConnectivityStatusContract(_Model): + """Details about connectivity to a resource. + + :ivar name: The hostname of the resource which the service depends on. This can be the + database, storage or any other azure resource on which the service depends upon. Required. + :vartype name: str + :ivar status: Resource Connectivity Status Type identifier. Required. Known values are: + "initializing", "success", and "failure". + :vartype status: str or ~azure.mgmt.apimanagement.models.ConnectivityStatusType + :ivar error: Error details of the connectivity to the resource. + :vartype error: str + :ivar last_updated: The date when the resource connectivity status was last updated. This + status should be updated every 15 minutes. If this status has not been updated, then it means + that the service has lost network connectivity to the resource, from inside the Virtual + Network.The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the + ISO 8601 standard. Required. + :vartype last_updated: ~datetime.datetime + :ivar last_status_change: The date when the resource connectivity status last Changed from + success to failure or vice-versa. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. + :vartype last_status_change: ~datetime.datetime + :ivar resource_type: Resource Type. Required. + :vartype resource_type: str + :ivar is_optional: Whether this is optional. Required. + :vartype is_optional: bool + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The hostname of the resource which the service depends on. This can be the database, storage or + any other azure resource on which the service depends upon. Required.""" + status: Union[str, "_models.ConnectivityStatusType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource Connectivity Status Type identifier. Required. Known values are: \"initializing\", + \"success\", and \"failure\".""" + error: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Error details of the connectivity to the resource.""" + last_updated: datetime.datetime = rest_field( + name="lastUpdated", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The date when the resource connectivity status was last updated. This status should be updated + every 15 minutes. If this status has not been updated, then it means that the service has lost + network connectivity to the resource, from inside the Virtual Network.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required.""" + last_status_change: datetime.datetime = rest_field( + name="lastStatusChange", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The date when the resource connectivity status last Changed from success to failure or + vice-versa. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by + the ISO 8601 standard. Required.""" + resource_type: str = rest_field(name="resourceType", visibility=["read", "create", "update", "delete", "query"]) + """Resource Type. Required.""" + is_optional: bool = rest_field(name="isOptional", visibility=["read", "create", "update", "delete", "query"]) + """Whether this is optional. Required.""" + + @overload + def __init__( + self, + *, + name: str, + status: Union[str, "_models.ConnectivityStatusType"], + last_updated: datetime.datetime, + last_status_change: datetime.datetime, + resource_type: str, + is_optional: bool, + error: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ContentItemContract(ProxyResource): + """Content type contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the content item. + :vartype properties: dict[str, any] + """ + + properties: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties of the content item.""" + + __flattened_items = [""] + + @overload + def __init__( + self, + *, + properties: Optional[dict[str, Any]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ContentTypeContract(ProxyResource): + """Content type contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the content type. + :vartype properties: ~azure.mgmt.apimanagement.models.ContentTypeContractProperties + """ + + properties: Optional["_models.ContentTypeContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the content type.""" + + __flattened_items = ["id", "name", "description", "schema", "version"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ContentTypeContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ContentTypeContractProperties(_Model): + """ContentTypeContractProperties. + + :ivar id: Content type identifier. + :vartype id: str + :ivar name: Content type name. Must be 1 to 250 characters long. + :vartype name: str + :ivar description: Content type description. + :vartype description: str + :ivar schema: Content type schema. + :vartype schema: any + :ivar version: Content type version. + :vartype version: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Content type identifier.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Content type name. Must be 1 to 250 characters long.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Content type description.""" + schema: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Content type schema.""" + version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Content type version.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + description: Optional[str] = None, + schema: Optional[Any] = None, + version: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DataMasking(_Model): + """DataMasking. + + :ivar query_params: Masking settings for Url query parameters. + :vartype query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + :ivar headers: Masking settings for headers. + :vartype headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + """ + + query_params: Optional[list["_models.DataMaskingEntity"]] = rest_field( + name="queryParams", visibility=["read", "create", "update", "delete", "query"] + ) + """Masking settings for Url query parameters.""" + headers: Optional[list["_models.DataMaskingEntity"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Masking settings for headers.""" + + @overload + def __init__( + self, + *, + query_params: Optional[list["_models.DataMaskingEntity"]] = None, + headers: Optional[list["_models.DataMaskingEntity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DataMaskingEntity(_Model): + """DataMaskingEntity. + + :ivar value: The name of an entity to mask (e.g. a name of a header or a query parameter). + :vartype value: str + :ivar mode: Data masking mode. Known values are: "Mask" and "Hide". + :vartype mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of an entity to mask (e.g. a name of a header or a query parameter).""" + mode: Optional[Union[str, "_models.DataMaskingMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Data masking mode. Known values are: \"Mask\" and \"Hide\".""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + mode: Optional[Union[str, "_models.DataMaskingMode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeletedServiceContract(ProxyResource): + """Deleted API Management Service information. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Deleted API Management Service details. + :vartype properties: ~azure.mgmt.apimanagement.models.DeletedServiceContractProperties + :ivar location: API Management Service Master Location. + :vartype location: str + """ + + properties: Optional["_models.DeletedServiceContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Deleted API Management Service details.""" + location: Optional[str] = rest_field(visibility=["read"]) + """API Management Service Master Location.""" + + __flattened_items = ["service_id", "scheduled_purge_date", "deletion_date"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DeletedServiceContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DeletedServiceContractProperties(_Model): + """DeletedServiceContractProperties. + + :ivar service_id: Fully-qualified API Management Service Resource ID. + :vartype service_id: str + :ivar scheduled_purge_date: UTC Date and Time when the service will be automatically purged. + The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 + standard. + :vartype scheduled_purge_date: ~datetime.datetime + :ivar deletion_date: UTC Timestamp when the service was soft-deleted. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype deletion_date: ~datetime.datetime + """ + + service_id: Optional[str] = rest_field(name="serviceId", visibility=["read", "create", "update", "delete", "query"]) + """Fully-qualified API Management Service Resource ID.""" + scheduled_purge_date: Optional[datetime.datetime] = rest_field( + name="scheduledPurgeDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """UTC Date and Time when the service will be automatically purged. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard.""" + deletion_date: Optional[datetime.datetime] = rest_field( + name="deletionDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """UTC Timestamp when the service was soft-deleted. The date conforms to the following format: + yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard.""" + + @overload + def __init__( + self, + *, + service_id: Optional[str] = None, + scheduled_purge_date: Optional[datetime.datetime] = None, + deletion_date: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeployConfigurationParameterProperties(_Model): + """Parameters supplied to the Deploy Configuration operation. + + :ivar branch: The name of the Git branch from which the configuration is to be deployed to the + configuration database. Required. + :vartype branch: str + :ivar force: The value enforcing deleting subscriptions to products that are deleted in this + update. + :vartype force: bool + """ + + branch: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the Git branch from which the configuration is to be deployed to the configuration + database. Required.""" + force: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The value enforcing deleting subscriptions to products that are deleted in this update.""" + + @overload + def __init__( + self, + *, + branch: str, + force: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DeployConfigurationParameters(_Model): + """Deploy Tenant Configuration Contract. + + :ivar properties: Deploy Configuration Parameter contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.DeployConfigurationParameterProperties + """ + + properties: Optional["_models.DeployConfigurationParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Deploy Configuration Parameter contract properties.""" + + __flattened_items = ["branch", "force"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DeployConfigurationParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DiagnosticContract(ProxyResource): + """Diagnostic details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Diagnostic entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.DiagnosticContractProperties + """ + + properties: Optional["_models.DiagnosticContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic entity contract properties.""" + + __flattened_items = [ + "always_log", + "logger_id", + "sampling", + "frontend", + "backend", + "large_language_model", + "log_client_ip", + "http_correlation_protocol", + "verbosity", + "operation_name_format", + "metrics", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DiagnosticContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DiagnosticContractProperties(_Model): + """Diagnostic Entity Properties. + + :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. Required. + :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 large_language_model: Large Language Models diagnostic settings. + :vartype large_language_model: ~azure.mgmt.apimanagement.models.LLMDiagnosticSettings + :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 + """ + + always_log: Optional[Union[str, "_models.AlwaysLog"]] = rest_field( + name="alwaysLog", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies for what type of messages sampling settings should not apply. \"allErrors\"""" + logger_id: str = rest_field(name="loggerId", visibility=["read", "create", "update", "delete", "query"]) + """Resource Id of a target logger. Required.""" + sampling: Optional["_models.SamplingSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Sampling settings for Diagnostic.""" + frontend: Optional["_models.PipelineDiagnosticSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway.""" + backend: Optional["_models.PipelineDiagnosticSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic settings for incoming/outgoing HTTP messages to the Backend.""" + large_language_model: Optional["_models.LLMDiagnosticSettings"] = rest_field( + name="largeLanguageModel", visibility=["read", "create", "update", "delete", "query"] + ) + """Large Language Models diagnostic settings.""" + log_client_ip: Optional[bool] = rest_field( + name="logClientIp", visibility=["read", "create", "update", "delete", "query"] + ) + """Log the ClientIP. Default is false.""" + http_correlation_protocol: Optional[Union[str, "_models.HttpCorrelationProtocol"]] = rest_field( + name="httpCorrelationProtocol", visibility=["read", "create", "update", "delete", "query"] + ) + """Sets correlation protocol to use for Application Insights diagnostics. Known values are: + \"None\", \"Legacy\", and \"W3C\".""" + verbosity: Optional[Union[str, "_models.Verbosity"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The verbosity level applied to traces emitted by trace policies. Known values are: \"verbose\", + \"information\", and \"error\".""" + operation_name_format: Optional[Union[str, "_models.OperationNameFormat"]] = rest_field( + name="operationNameFormat", visibility=["read", "create", "update", "delete", "query"] + ) + """The format of the Operation Name for Application Insights telemetries. Default is Name. Known + values are: \"Name\" and \"Url\".""" + metrics: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Emit custom metrics via emit-metric policy. Applicable only to Application Insights diagnostic + settings.""" + + @overload + def __init__( + self, + *, + logger_id: str, + always_log: Optional[Union[str, "_models.AlwaysLog"]] = None, + sampling: Optional["_models.SamplingSettings"] = None, + frontend: Optional["_models.PipelineDiagnosticSettings"] = None, + backend: Optional["_models.PipelineDiagnosticSettings"] = None, + large_language_model: Optional["_models.LLMDiagnosticSettings"] = 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DiagnosticContractUpdateProperties(_Model): + """Diagnostic Entity Properties. + + :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 + """ + + always_log: Optional[Union[str, "_models.AlwaysLog"]] = rest_field( + name="alwaysLog", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies for what type of messages sampling settings should not apply. \"allErrors\"""" + logger_id: Optional[str] = rest_field(name="loggerId", visibility=["read", "create", "update", "delete", "query"]) + """Resource Id of a target logger.""" + sampling: Optional["_models.SamplingSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Sampling settings for Diagnostic.""" + frontend: Optional["_models.PipelineDiagnosticSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway.""" + backend: Optional["_models.PipelineDiagnosticSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic settings for incoming/outgoing HTTP messages to the Backend.""" + log_client_ip: Optional[bool] = rest_field( + name="logClientIp", visibility=["read", "create", "update", "delete", "query"] + ) + """Log the ClientIP. Default is false.""" + http_correlation_protocol: Optional[Union[str, "_models.HttpCorrelationProtocol"]] = rest_field( + name="httpCorrelationProtocol", visibility=["read", "create", "update", "delete", "query"] + ) + """Sets correlation protocol to use for Application Insights diagnostics. Known values are: + \"None\", \"Legacy\", and \"W3C\".""" + verbosity: Optional[Union[str, "_models.Verbosity"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The verbosity level applied to traces emitted by trace policies. Known values are: \"verbose\", + \"information\", and \"error\".""" + operation_name_format: Optional[Union[str, "_models.OperationNameFormat"]] = rest_field( + name="operationNameFormat", visibility=["read", "create", "update", "delete", "query"] + ) + """The format of the Operation Name for Application Insights telemetries. Default is Name. Known + values are: \"Name\" and \"Url\".""" + metrics: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Emit custom metrics via emit-metric policy. Applicable only to Application Insights diagnostic + settings.""" + + @overload + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DiagnosticUpdateContract(ProxyResource): + """Diagnostic details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Diagnostic entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.DiagnosticContractUpdateProperties + """ + + properties: Optional["_models.DiagnosticContractUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic entity contract properties.""" + + __flattened_items = [ + "always_log", + "logger_id", + "sampling", + "frontend", + "backend", + "log_client_ip", + "http_correlation_protocol", + "verbosity", + "operation_name_format", + "metrics", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DiagnosticContractUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DocumentationContract(ProxyResource): + """Markdown documentation details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Markdown Documentation details. + :vartype properties: ~azure.mgmt.apimanagement.models.DocumentationContractProperties + """ + + properties: Optional["_models.DocumentationContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Markdown Documentation details.""" + + __flattened_items = ["title", "content"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DocumentationContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class DocumentationContractProperties(_Model): + """Markdown documentation details. + + :ivar title: documentation title. + :vartype title: str + :ivar content: Markdown documentation content. + :vartype content: str + """ + + title: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """documentation title.""" + content: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Markdown documentation content.""" + + @overload + def __init__( + self, + *, + title: Optional[str] = None, + content: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class DocumentationUpdateContract(_Model): + """Documentation update contract details. + + :ivar properties: Markdown Documentation details. + :vartype properties: ~azure.mgmt.apimanagement.models.DocumentationContractProperties + """ + + properties: Optional["_models.DocumentationContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Markdown Documentation details.""" + + __flattened_items = ["title", "content"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.DocumentationContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class EmailTemplateContract(ProxyResource): + """Email Template details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Email Template entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.EmailTemplateContractProperties + """ + + properties: Optional["_models.EmailTemplateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Email Template entity contract properties.""" + + __flattened_items = ["subject", "body", "title", "description", "is_default", "parameters"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.EmailTemplateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class EmailTemplateContractProperties(_Model): + """Email Template Contract properties. + + :ivar subject: Subject of the Template. Required. + :vartype subject: str + :ivar body: Email Template Body. This should be a valid XDocument. Required. + :vartype body: str + :ivar title: Title of the Template. + :vartype title: str + :ivar description: Description of the Email Template. + :vartype description: str + :ivar is_default: Whether the template is the default template provided by API Management or + has been edited. + :vartype is_default: bool + :ivar parameters: Email Template Parameter values. + :vartype parameters: + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] + """ + + subject: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Subject of the Template. Required.""" + body: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Email Template Body. This should be a valid XDocument. Required.""" + title: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Title of the Template.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the Email Template.""" + is_default: Optional[bool] = rest_field(name="isDefault", visibility=["read"]) + """Whether the template is the default template provided by API Management or has been edited.""" + parameters: Optional[list["_models.EmailTemplateParametersContractProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Email Template Parameter values.""" + + @overload + def __init__( + self, + *, + subject: str, + body: str, + title: Optional[str] = None, + description: Optional[str] = None, + parameters: Optional[list["_models.EmailTemplateParametersContractProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EmailTemplateParametersContractProperties(_Model): # pylint: disable=name-too-long + """Email Template Parameter contract. + + :ivar name: Template parameter name. + :vartype name: str + :ivar title: Template parameter title. + :vartype title: str + :ivar description: Template parameter description. + :vartype description: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Template parameter name.""" + title: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Template parameter title.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Template parameter description.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EmailTemplateUpdateParameterProperties(_Model): + """Email Template Update Contract properties. + + :ivar subject: Subject of the Template. + :vartype subject: str + :ivar title: Title of the Template. + :vartype title: str + :ivar description: Description of the Email Template. + :vartype description: str + :ivar body: Email Template Body. This should be a valid XDocument. + :vartype body: str + :ivar parameters: Email Template Parameter values. + :vartype parameters: + list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] + """ + + subject: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Subject of the Template.""" + title: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Title of the Template.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the Email Template.""" + body: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Email Template Body. This should be a valid XDocument.""" + parameters: Optional[list["_models.EmailTemplateParametersContractProperties"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Email Template Parameter values.""" + + @overload + def __init__( + self, + *, + subject: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + body: Optional[str] = None, + parameters: Optional[list["_models.EmailTemplateParametersContractProperties"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EmailTemplateUpdateParameters(_Model): + """Email Template update Parameters. + + :ivar properties: Email Template Update contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameterProperties + """ + + properties: Optional["_models.EmailTemplateUpdateParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Email Template Update contract properties.""" + + __flattened_items = ["subject", "title", "description", "body", "parameters"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.EmailTemplateUpdateParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class EndpointDependency(_Model): + """A domain name that a service is reached at. + + :ivar domain_name: The domain name of the dependency. + :vartype domain_name: str + :ivar endpoint_details: The Ports used when connecting to DomainName. + :vartype endpoint_details: list[~azure.mgmt.apimanagement.models.EndpointDetail] + """ + + domain_name: Optional[str] = rest_field( + name="domainName", visibility=["read", "create", "update", "delete", "query"] + ) + """The domain name of the dependency.""" + endpoint_details: Optional[list["_models.EndpointDetail"]] = rest_field( + name="endpointDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """The Ports used when connecting to DomainName.""" + + @overload + def __init__( + self, + *, + domain_name: Optional[str] = None, + endpoint_details: Optional[list["_models.EndpointDetail"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class EndpointDetail(_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 + """ + + port: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The port an endpoint is connected to.""" + region: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The region of the dependency.""" + + @overload + def __init__( + self, + *, + port: Optional[int] = None, + region: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorAdditionalInfo(_Model): + """The resource management error additional info. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The additional info type.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The additional info.""" + + +class ErrorDetail(_Model): + """The error detail. + + :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] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """The error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """The error message.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The error target.""" + details: Optional[list["_models.ErrorDetail"]] = rest_field(visibility=["read"]) + """The error details.""" + additional_info: Optional[list["_models.ErrorAdditionalInfo"]] = rest_field( + name="additionalInfo", visibility=["read"] + ) + """The error additional info.""" + + +class ErrorFieldContract(_Model): + """Error Field contract. + + :ivar code: Property level error code. + :vartype code: str + :ivar message: Human-readable representation of property-level error. + :vartype message: str + :ivar target: Property name. + :vartype target: str + """ + + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Property level error code.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Human-readable representation of property-level error.""" + target: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Property name.""" + + @overload + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error object. + :vartype error: ~azure.mgmt.apimanagement.models.ErrorDetail + """ + + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error object.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDetail"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorResponseBody(_Model): + """Error Body contract. + + :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] + """ + + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Service-defined error code. This code serves as a sub-status for the HTTP error code specified + in the response.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Human-readable representation of the error.""" + details: Optional[list["_models.ErrorFieldContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The list of invalid fields send in request, in case of validation error.""" + + @overload + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + details: Optional[list["_models.ErrorFieldContract"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FailureStatusCodeRange(_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 + """ + + min: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The minimum http status code.""" + max: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The maximum http status code.""" + + @overload + def __init__( + self, + *, + min: Optional[int] = None, # pylint: disable=redefined-builtin + max: Optional[int] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FrontendConfiguration(_Model): + """Information regarding how the gateway should be exposed. + + :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 + """ + + default_hostname: Optional[str] = rest_field(name="defaultHostname", visibility=["read"]) + """The default hostname of the data-plane gateway to which requests can be sent. This is only + applicable for API gateway with Standard SKU.""" + + +class GatewayCertificateAuthorityContract(ProxyResource): + """Gateway certificate authority details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Gateway certificate authority details. + :vartype properties: + ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContractProperties + """ + + properties: Optional["_models.GatewayCertificateAuthorityContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Gateway certificate authority details.""" + + __flattened_items = ["is_trusted"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.GatewayCertificateAuthorityContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class GatewayCertificateAuthorityContractProperties(_Model): # pylint: disable=name-too-long + """Gateway certificate authority details. + + :ivar is_trusted: Determines whether certificate authority is trusted. + :vartype is_trusted: bool + """ + + is_trusted: Optional[bool] = rest_field( + name="isTrusted", visibility=["read", "create", "update", "delete", "query"] + ) + """Determines whether certificate authority is trusted.""" + + @overload + def __init__( + self, + *, + is_trusted: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayConfigConnectionBaseProperties(_Model): + """GatewayConfigConnectionBaseProperties. + + :ivar provisioning_state: The current provisioning state of the API Management gateway config + connection. + :vartype provisioning_state: str + :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] + """ + + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The current provisioning state of the API Management gateway config connection.""" + source_id: Optional[str] = rest_field(name="sourceId", visibility=["read", "create", "update", "delete", "query"]) + """The link to the API Management service workspace.""" + default_hostname: Optional[str] = rest_field(name="defaultHostname", visibility=["read"]) + """The default hostname of the data-plane gateway.""" + hostnames: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The hostnames of the data-plane gateway to which requests can be sent.""" + + @overload + def __init__( + self, + *, + source_id: Optional[str] = None, + hostnames: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayConfigurationApi(_Model): + """Information regarding the Configuration API of the API Management gateway. This is only + applicable for API gateway with Standard SKU. + + :ivar hostname: Hostname to which the agent connects to propagate configuration to the cloud. + :vartype hostname: str + """ + + hostname: Optional[str] = rest_field(visibility=["read"]) + """Hostname to which the agent connects to propagate configuration to the cloud.""" + + +class GatewayContract(ProxyResource): + """Gateway details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Gateway details. + :vartype properties: ~azure.mgmt.apimanagement.models.GatewayContractProperties + :ivar identity: The managed service identities assigned to this resource. + :vartype identity: ~azure.mgmt.apimanagement.models.ManagedServiceIdentity + """ + + properties: Optional["_models.GatewayContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Gateway details.""" + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The managed service identities assigned to this resource.""" + + __flattened_items = ["location_data", "description"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.GatewayContractProperties"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class GatewayContractProperties(_Model): + """Properties of the Gateway contract. + + :ivar location_data: Gateway location. + :vartype location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract + :ivar description: Gateway description. + :vartype description: str + """ + + location_data: Optional["_models.ResourceLocationDataContract"] = rest_field( + name="locationData", visibility=["read", "create", "update", "delete", "query"] + ) + """Gateway location.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gateway description.""" + + @overload + def __init__( + self, + *, + location_data: Optional["_models.ResourceLocationDataContract"] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayDebugCredentialsContract(_Model): + """Gateway debug credentials. + + :ivar token: Gateway debug token. + :vartype token: str + """ + + token: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Gateway debug token.""" + + @overload + def __init__( + self, + *, + token: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayHostnameBindingBaseProperties(_Model): + """GatewayHostnameBindingBaseProperties. + + :ivar provisioning_state: The current provisioning state of the API Management gateway hostname + binding. + :vartype provisioning_state: str + :ivar hostname: The default hostname of the data-plane gateway. Required. + :vartype hostname: str + :ivar key_vault: The link to the API Management service workspace. Required. + :vartype key_vault: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingKeyVault + :ivar certificate: The hostnames of the data-plane gateway to which requests can be sent. + :vartype certificate: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingCertificate + """ + + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The current provisioning state of the API Management gateway hostname binding.""" + hostname: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The default hostname of the data-plane gateway. Required.""" + key_vault: "_models.GatewayHostnameBindingKeyVault" = rest_field( + name="keyVault", visibility=["read", "create", "update", "delete", "query"] + ) + """The link to the API Management service workspace. Required.""" + certificate: Optional["_models.GatewayHostnameBindingCertificate"] = rest_field(visibility=["read"]) + """The hostnames of the data-plane gateway to which requests can be sent.""" + + @overload + def __init__( + self, + *, + hostname: str, + key_vault: "_models.GatewayHostnameBindingKeyVault", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayHostnameBindingCertificate(_Model): + """GatewayHostnameBindingCertificate. + + :ivar thumbprint: The thumbprint of the certificate. + :vartype thumbprint: str + :ivar subject: The subject of the certificate. + :vartype subject: str + :ivar expiry: The expiration date of the certificate. + :vartype expiry: ~datetime.datetime + """ + + thumbprint: Optional[str] = rest_field(visibility=["read"]) + """The thumbprint of the certificate.""" + subject: Optional[str] = rest_field(visibility=["read"]) + """The subject of the certificate.""" + expiry: Optional[datetime.datetime] = rest_field(visibility=["read"], format="rfc3339") + """The expiration date of the certificate.""" + + +class GatewayHostnameBindingKeyVault(_Model): + """GatewayHostnameBindingKeyVault. + + :ivar secret_id: The current provisioning state of the API Management gateway hostname binding. + Required. + :vartype secret_id: str + :ivar identity_client_id: The default hostname of the data-plane gateway. + :vartype identity_client_id: str + :ivar last_status: The last status of the Key Vault certificate fetch process. + :vartype last_status: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingKeyVaultLastStatus + """ + + secret_id: str = rest_field(name="secretId", visibility=["read", "create", "update", "delete", "query"]) + """The current provisioning state of the API Management gateway hostname binding. Required.""" + identity_client_id: Optional[str] = rest_field( + name="identityClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """The default hostname of the data-plane gateway.""" + last_status: Optional["_models.GatewayHostnameBindingKeyVaultLastStatus"] = rest_field( + name="lastStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """The last status of the Key Vault certificate fetch process.""" + + @overload + def __init__( + self, + *, + secret_id: str, + identity_client_id: Optional[str] = None, + last_status: Optional["_models.GatewayHostnameBindingKeyVaultLastStatus"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayHostnameBindingKeyVaultLastStatus(_Model): + """GatewayHostnameBindingKeyVaultLastStatus. + + :ivar code: The last status of the Key Vault certificate fetch process. Known values are: + "Success" and "Failed". + :vartype code: str or ~azure.mgmt.apimanagement.models.KeyVaultFetchCode + :ivar time_stamp_utc: The last time the Key Vault certificate fetch process was attempted. The + date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :vartype time_stamp_utc: ~datetime.datetime + :ivar last_success_time_stamp_utc: The last time the Key Vault certificate fetch process was + successful. Only when the fetch process has succeeded at least once and current state is + failed. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by + the ISO 8601 standard. + :vartype last_success_time_stamp_utc: ~datetime.datetime + """ + + code: Optional[Union[str, "_models.KeyVaultFetchCode"]] = rest_field(visibility=["read"]) + """The last status of the Key Vault certificate fetch process. Known values are: \"Success\" and + \"Failed\".""" + time_stamp_utc: Optional[datetime.datetime] = rest_field(name="timeStampUtc", visibility=["read"], format="rfc3339") + """The last time the Key Vault certificate fetch process was attempted. The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + last_success_time_stamp_utc: Optional[datetime.datetime] = rest_field( + name="lastSuccessTimeStampUtc", visibility=["read"], format="rfc3339" + ) + """The last time the Key Vault certificate fetch process was successful. Only when the fetch + process has succeeded at least once and current state is failed. The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + + +class GatewayHostnameBindingResource(ProxyResource): + """A single API Management gateway hostname binding resource in List or Get response. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the API Management gateway hostname binding. Required. + :vartype properties: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingBaseProperties + :ivar etag: If eTag is provided in the response body, it may also be provided as a header per + the normal etag convention. Entity tags are used for comparing two or more entities from the + same requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match + (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. + :vartype etag: str + """ + + properties: "_models.GatewayHostnameBindingBaseProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API Management gateway hostname binding. Required.""" + etag: Optional[str] = rest_field(visibility=["read"]) + """If eTag is provided in the response body, it may also be provided as a header per the normal + etag convention. Entity tags are used for comparing two or more entities from the same + requested resource. HTTP/1.1 uses entity tags in the etag (section 14.19), If-Match (section + 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields.""" + + __flattened_items = ["provisioning_state", "hostname", "key_vault", "certificate"] + + @overload + def __init__( + self, + *, + properties: "_models.GatewayHostnameBindingBaseProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class GatewayHostnameConfigurationContract(ProxyResource): + """Gateway hostname configuration details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Gateway hostname configuration details. + :vartype properties: + ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContractProperties + """ + + properties: Optional["_models.GatewayHostnameConfigurationContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Gateway hostname configuration details.""" + + __flattened_items = [ + "hostname", + "certificate_id", + "negotiate_client_certificate", + "tls10_enabled", + "tls11_enabled", + "http2_enabled", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.GatewayHostnameConfigurationContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class GatewayHostnameConfigurationContractProperties(_Model): # pylint: disable=name-too-long + """Gateway hostname configuration details. + + :ivar hostname: Hostname value. Supports valid domain name, partial or full wildcard. + :vartype hostname: str + :ivar certificate_id: Identifier of Certificate entity that will be used for TLS connection + establishment. + :vartype certificate_id: str + :ivar negotiate_client_certificate: Determines whether gateway requests client certificate. + :vartype negotiate_client_certificate: bool + :ivar tls10_enabled: Specifies if TLS 1.0 is supported. + :vartype tls10_enabled: bool + :ivar tls11_enabled: Specifies if TLS 1.1 is supported. + :vartype tls11_enabled: bool + :ivar http2_enabled: Specifies if HTTP/2.0 is supported. + :vartype http2_enabled: bool + """ + + hostname: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Hostname value. Supports valid domain name, partial or full wildcard.""" + certificate_id: Optional[str] = rest_field( + name="certificateId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of Certificate entity that will be used for TLS connection establishment.""" + negotiate_client_certificate: Optional[bool] = rest_field( + name="negotiateClientCertificate", visibility=["read", "create", "update", "delete", "query"] + ) + """Determines whether gateway requests client certificate.""" + tls10_enabled: Optional[bool] = rest_field( + name="tls10Enabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies if TLS 1.0 is supported.""" + tls11_enabled: Optional[bool] = rest_field( + name="tls11Enabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies if TLS 1.1 is supported.""" + http2_enabled: Optional[bool] = rest_field( + name="http2Enabled", visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies if HTTP/2.0 is supported.""" + + @overload + def __init__( + self, + *, + hostname: Optional[str] = None, + certificate_id: Optional[str] = None, + negotiate_client_certificate: Optional[bool] = None, + tls10_enabled: Optional[bool] = None, + tls11_enabled: Optional[bool] = None, + http2_enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayKeyRegenerationRequestContract(_Model): + """Gateway key regeneration request contract properties. + + :ivar key_type: The Key being regenerated. Required. Known values are: "primary" and + "secondary". + :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType + """ + + key_type: Union[str, "_models.KeyType"] = rest_field( + name="keyType", visibility=["read", "create", "update", "delete", "query"] + ) + """The Key being regenerated. Required. Known values are: \"primary\" and \"secondary\".""" + + @overload + def __init__( + self, + *, + key_type: Union[str, "_models.KeyType"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayKeysContract(_Model): + """Gateway authentication keys. + + :ivar primary: Primary gateway key. + :vartype primary: str + :ivar secondary: Secondary gateway key. + :vartype secondary: str + """ + + primary: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Primary gateway key.""" + secondary: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Secondary gateway key.""" + + @overload + def __init__( + self, + *, + primary: Optional[str] = None, + secondary: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayListDebugCredentialsContract(_Model): + """List debug credentials properties. + + :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 + """ + + credentials_expire_after: Optional[datetime.timedelta] = rest_field( + name="credentialsExpireAfter", visibility=["read", "create", "update", "delete", "query"] + ) + """Credentials expiration in ISO8601 format. Maximum duration of the credentials is PT1H. When + property is not specified, them value PT1H is used.""" + purposes: list[Union[str, "_models.GatewayListDebugCredentialsContractPurpose"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Purposes of debug credential. Required.""" + api_id: str = rest_field(name="apiId", visibility=["read", "create", "update", "delete", "query"]) + """Full resource Id of an API. Required.""" + + @overload + def __init__( + self, + *, + purposes: list[Union[str, "_models.GatewayListDebugCredentialsContractPurpose"]], + api_id: str, + credentials_expire_after: Optional[datetime.timedelta] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayListTraceContract(_Model): + """List trace properties. + + :ivar trace_id: Trace id. + :vartype trace_id: str + """ + + trace_id: Optional[str] = rest_field(name="traceId", visibility=["read", "create", "update", "delete", "query"]) + """Trace id.""" + + @overload + def __init__( + self, + *, + trace_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayResourceSkuResult(_Model): + """Describes an available API Management gateway SKU. + + :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 + """ + + resource_type: Optional[str] = rest_field(name="resourceType", visibility=["read"]) + """The type of resource the SKU applies to.""" + sku: Optional["_models.GatewaySku"] = rest_field(visibility=["read"]) + """Specifies API Management gateway SKU.""" + capacity: Optional["_models.GatewaySkuCapacity"] = rest_field(visibility=["read"]) + """Specifies the number of API Management gateway units.""" + + +class GatewaySku(_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.ApiGatewaySkuType + """ + + name: Optional[Union[str, "_models.ApiGatewaySkuType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the Sku. Known values are: \"Standard\", \"WorkspaceGatewayStandard\", and + \"WorkspaceGatewayPremium\".""" + + @overload + def __init__( + self, + *, + name: Optional[Union[str, "_models.ApiGatewaySkuType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewaySkuCapacity(_Model): + """Describes scaling information of a SKU. + + :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 + """ + + minimum: Optional[int] = rest_field(visibility=["read"]) + """The minimum capacity.""" + maximum: Optional[int] = rest_field(visibility=["read"]) + """The maximum capacity that can be set.""" + default: Optional[int] = rest_field(visibility=["read"]) + """The default capacity.""" + scale_type: Optional[Union[str, "_models.GatewaySkuCapacityScaleType"]] = rest_field( + name="scaleType", visibility=["read"] + ) + """The scale type applicable to the sku. Known values are: \"Automatic\", \"Manual\", and + \"None\".""" + + +class GatewayTokenContract(_Model): + """Gateway access token. + + :ivar value: Shared Access Authentication token value for the Gateway. + :vartype value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Shared Access Authentication token value for the Gateway.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GatewayTokenRequestContract(_Model): + """Gateway token request contract properties. + + :ivar key_type: The Key to be used to generate gateway token. Required. Known values are: + "primary" and "secondary". + :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType + :ivar expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The + date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. Required. + :vartype expiry: ~datetime.datetime + """ + + key_type: Union[str, "_models.KeyType"] = rest_field( + name="keyType", visibility=["read", "create", "update", "delete", "query"] + ) + """The Key to be used to generate gateway token. Required. Known values are: \"primary\" and + \"secondary\".""" + expiry: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc3339") + """The Expiry time of the Token. Maximum token expiry time is set to 30 days. The date conforms to + the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required.""" + + @overload + def __init__( + self, + *, + key_type: Union[str, "_models.KeyType"], + expiry: datetime.datetime, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GenerateSsoUrlResult(_Model): + """Generate SSO Url operations response details. + + :ivar value: Redirect Url containing the SSO URL value. + :vartype value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Redirect Url containing the SSO URL value.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GlobalSchemaContract(ProxyResource): + """Global Schema Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Global Schema. + :vartype properties: ~azure.mgmt.apimanagement.models.GlobalSchemaContractProperties + """ + + properties: Optional["_models.GlobalSchemaContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Global Schema.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.GlobalSchemaContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GlobalSchemaContractProperties(_Model): + """Schema create or update contract Properties. + + :ivar schema_type: Schema Type. Immutable. Required. Known values are: "xml" and "json". + :vartype schema_type: str or ~azure.mgmt.apimanagement.models.SchemaType + :ivar description: Free-form schema entity description. + :vartype description: str + :ivar value: Json-encoded string for non json-based schema. + :vartype value: any + :ivar document: Global Schema document object for json-based schema formats(e.g. json schema). + :vartype document: any + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + schema_type: Union[str, "_models.SchemaType"] = rest_field( + name="schemaType", visibility=["read", "create", "update", "delete", "query"] + ) + """Schema Type. Immutable. Required. Known values are: \"xml\" and \"json\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Free-form schema entity description.""" + value: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Json-encoded string for non json-based schema.""" + document: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Global Schema document object for json-based schema formats(e.g. json schema).""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The provisioning state.""" + + __flattened_items = [""] + + @overload + def __init__( + self, + *, + schema_type: Union[str, "_models.SchemaType"], + description: Optional[str] = None, + value: Optional[Any] = None, + document: Optional[Any] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.document is None: + return None + return getattr(self.document, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.document is None: + self.document = self._attr_to_rest_field["document"]._class_type() + setattr(self.document, key, value) + else: + super().__setattr__(key, value) + + +class GroupContract(ProxyResource): + """Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Group entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.GroupContractProperties + """ + + properties: Optional["_models.GroupContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Group entity contract properties.""" + + __flattened_items = ["display_name", "description", "built_in", "type", "external_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.GroupContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class GroupContractProperties(_Model): + """Group contract Properties. + + :ivar display_name: Group name. Required. + :vartype display_name: str + :ivar description: Group description. Can contain HTML formatting tags. + :vartype description: str + :ivar built_in: true if the group is one of the three system groups (Administrators, + Developers, or Guests); otherwise false. + :vartype built_in: bool + :ivar type: Group type. Known values are: "custom", "system", and "external". + :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. + :vartype external_id: str + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Group name. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Group description. Can contain HTML formatting tags.""" + built_in: Optional[bool] = rest_field(name="builtIn", visibility=["read"]) + """true if the group is one of the three system groups (Administrators, Developers, or Guests); + otherwise false.""" + type: Optional[Union[str, "_models.GroupType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Group type. Known values are: \"custom\", \"system\", and \"external\".""" + external_id: Optional[str] = rest_field( + name="externalId", visibility=["read", "create", "update", "delete", "query"] + ) + """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.""" + + @overload + def __init__( + self, + *, + display_name: str, + description: Optional[str] = None, + type: Optional[Union[str, "_models.GroupType"]] = None, + external_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GroupCreateParameters(_Model): + """Parameters supplied to the Create Group operation. + + :ivar properties: Properties supplied to Create Group operation. + :vartype properties: ~azure.mgmt.apimanagement.models.GroupCreateParametersProperties + """ + + properties: Optional["_models.GroupCreateParametersProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties supplied to Create Group operation.""" + + __flattened_items = ["display_name", "description", "type", "external_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.GroupCreateParametersProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class GroupCreateParametersProperties(_Model): + """Parameters supplied to the Create Group operation. + + :ivar display_name: Group name. Required. + :vartype display_name: str + :ivar description: Group description. + :vartype description: str + :ivar type: Group type. Known values are: "custom", "system", and "external". + :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. + :vartype external_id: str + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Group name. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Group description.""" + type: Optional[Union[str, "_models.GroupType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Group type. Known values are: \"custom\", \"system\", and \"external\".""" + external_id: Optional[str] = rest_field( + name="externalId", visibility=["read", "create", "update", "delete", "query"] + ) + """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.""" + + @overload + def __init__( + self, + *, + display_name: str, + description: Optional[str] = None, + type: Optional[Union[str, "_models.GroupType"]] = None, + external_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class GroupUpdateParameters(_Model): + """Parameters supplied to the Update Group operation. + + :ivar properties: Group entity update contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.GroupUpdateParametersProperties + """ + + properties: Optional["_models.GroupUpdateParametersProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Group entity update contract properties.""" + + __flattened_items = ["display_name", "description", "type", "external_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.GroupUpdateParametersProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class GroupUpdateParametersProperties(_Model): + """Parameters supplied to the Update Group operation. + + :ivar display_name: Group name. + :vartype display_name: str + :ivar description: Group description. + :vartype description: str + :ivar type: Group type. Known values are: "custom", "system", and "external". + :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. + :vartype external_id: str + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Group name.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Group description.""" + type: Optional[Union[str, "_models.GroupType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Group type. Known values are: \"custom\", \"system\", and \"external\".""" + external_id: Optional[str] = rest_field( + name="externalId", visibility=["read", "create", "update", "delete", "query"] + ) + """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.""" + + @overload + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + type: Optional[Union[str, "_models.GroupType"]] = None, + external_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class HostnameConfiguration(_Model): + """Custom hostname configuration. + + :ivar type: Hostname type. Required. Known values are: "Proxy", "Portal", "Management", "Scm", + "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 + :ivar key_vault_id: Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url + containing version is provided, auto-update of ssl certificate will not work. This requires Api + Management service to be configured with aka.ms/apimmsi. The secret should be of type + *application/x-pkcs12*. + :vartype key_vault_id: str + :ivar identity_client_id: System or User Assigned Managed identity clientId as generated by + Azure AD, which has GET access to the keyVault containing the SSL certificate. + :vartype identity_client_id: str + :ivar encoded_certificate: Base64 Encoded certificate. + :vartype encoded_certificate: str + :ivar certificate_password: Certificate Password. + :vartype certificate_password: str + :ivar default_ssl_binding: Specify true to setup the certificate associated with this Hostname + as the Default SSL Certificate. If a client does not send the SNI header, then this will be the + certificate that will be challenged. The property is useful if a service has multiple custom + hostname enabled and it needs to decide on the default ssl certificate. The setting only + applied to gateway Hostname Type. + :vartype default_ssl_binding: bool + :ivar negotiate_client_certificate: Specify true to always negotiate client certificate on the + hostname. Default Value is false. + :vartype negotiate_client_certificate: bool + :ivar certificate: Certificate information. + :vartype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation + :ivar certificate_source: Certificate Source. Known values are: "Managed", "KeyVault", + "Custom", and "BuiltIn". + :vartype certificate_source: str or ~azure.mgmt.apimanagement.models.CertificateSource + :ivar certificate_status: Certificate Status. Known values are: "Completed", "Failed", and + "InProgress". + :vartype certificate_status: str or ~azure.mgmt.apimanagement.models.CertificateStatus + """ + + type: Union[str, "_models.HostnameType"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Hostname type. Required. Known values are: \"Proxy\", \"Portal\", \"Management\", \"Scm\", + \"DeveloperPortal\", and \"ConfigurationApi\".""" + host_name: str = rest_field(name="hostName", visibility=["read", "create", "update", "delete", "query"]) + """Hostname to configure on the Api Management service. Required.""" + key_vault_id: Optional[str] = rest_field( + name="keyVaultId", visibility=["read", "create", "update", "delete", "query"] + ) + """Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url containing version + is provided, auto-update of ssl certificate will not work. This requires Api Management service + to be configured with aka.ms/apimmsi. The secret should be of type *application/x-pkcs12*.""" + identity_client_id: Optional[str] = rest_field( + name="identityClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """System or User Assigned Managed identity clientId as generated by Azure AD, which has GET + access to the keyVault containing the SSL certificate.""" + encoded_certificate: Optional[str] = rest_field( + name="encodedCertificate", visibility=["read", "create", "update", "delete", "query"] + ) + """Base64 Encoded certificate.""" + certificate_password: Optional[str] = rest_field( + name="certificatePassword", visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate Password.""" + default_ssl_binding: Optional[bool] = rest_field( + name="defaultSslBinding", visibility=["read", "create", "update", "delete", "query"] + ) + """Specify true to setup the certificate associated with this Hostname as the Default SSL + Certificate. If a client does not send the SNI header, then this will be the certificate that + will be challenged. The property is useful if a service has multiple custom hostname enabled + and it needs to decide on the default ssl certificate. The setting only applied to gateway + Hostname Type.""" + negotiate_client_certificate: Optional[bool] = rest_field( + name="negotiateClientCertificate", visibility=["read", "create", "update", "delete", "query"] + ) + """Specify true to always negotiate client certificate on the hostname. Default Value is false.""" + certificate: Optional["_models.CertificateInformation"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate information.""" + certificate_source: Optional[Union[str, "_models.CertificateSource"]] = rest_field( + name="certificateSource", visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate Source. Known values are: \"Managed\", \"KeyVault\", \"Custom\", and \"BuiltIn\".""" + certificate_status: Optional[Union[str, "_models.CertificateStatus"]] = rest_field( + name="certificateStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate Status. Known values are: \"Completed\", \"Failed\", and \"InProgress\".""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.HostnameType"], + host_name: str, + key_vault_id: Optional[str] = None, + identity_client_id: Optional[str] = None, + encoded_certificate: Optional[str] = None, + certificate_password: Optional[str] = None, + default_ssl_binding: Optional[bool] = None, + negotiate_client_certificate: Optional[bool] = None, + certificate: Optional["_models.CertificateInformation"] = None, + certificate_source: Optional[Union[str, "_models.CertificateSource"]] = None, + certificate_status: Optional[Union[str, "_models.CertificateStatus"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class HTTPHeader(_Model): + """HTTP header and it's value. + + :ivar name: Header name. Required. + :vartype name: str + :ivar value: Header value. Required. + :vartype value: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Header name. Required.""" + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Header value. Required.""" + + @overload + def __init__( + self, + *, + name: str, + value: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class HttpMessageDiagnostic(_Model): + """Http message diagnostic settings. + + :ivar headers: Array of HTTP Headers to log. + :vartype headers: list[str] + :ivar body: Body logging settings. + :vartype body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings + :ivar data_masking: Data masking settings. + :vartype data_masking: ~azure.mgmt.apimanagement.models.DataMasking + """ + + headers: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Array of HTTP Headers to log.""" + body: Optional["_models.BodyDiagnosticSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Body logging settings.""" + data_masking: Optional["_models.DataMasking"] = rest_field( + name="dataMasking", visibility=["read", "create", "update", "delete", "query"] + ) + """Data masking settings.""" + + @overload + def __init__( + self, + *, + headers: Optional[list[str]] = None, + body: Optional["_models.BodyDiagnosticSettings"] = None, + data_masking: Optional["_models.DataMasking"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IdentityProviderBaseParameters(_Model): + """Identity Provider Base Parameter Properties. + + :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", + "microsoft", "twitter", "aad", and "aadB2C". + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str + """ + + type: Optional[Union[str, "_models.IdentityProviderType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Identity Provider Type identifier. Known values are: \"facebook\", \"google\", \"microsoft\", + \"twitter\", \"aad\", and \"aadB2C\".""" + signin_tenant: Optional[str] = rest_field( + name="signinTenant", visibility=["read", "create", "update", "delete", "query"] + ) + """The TenantId to use instead of Common when logging into Active Directory.""" + allowed_tenants: Optional[list[str]] = rest_field( + name="allowedTenants", visibility=["read", "create", "update", "delete", "query"] + ) + """List of Allowed Tenants when configuring Azure Active Directory login.""" + authority: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """OpenID Connect discovery endpoint hostname for AAD or AAD B2C.""" + signup_policy_name: Optional[str] = rest_field( + name="signupPolicyName", visibility=["read", "create", "update", "delete", "query"] + ) + """Signup Policy Name. Only applies to AAD B2C Identity Provider.""" + signin_policy_name: Optional[str] = rest_field( + name="signinPolicyName", visibility=["read", "create", "update", "delete", "query"] + ) + """Signin Policy Name. Only applies to AAD B2C Identity Provider.""" + profile_editing_policy_name: Optional[str] = rest_field( + name="profileEditingPolicyName", visibility=["read", "create", "update", "delete", "query"] + ) + """Profile Editing Policy Name. Only applies to AAD B2C Identity Provider.""" + password_reset_policy_name: Optional[str] = rest_field( + name="passwordResetPolicyName", visibility=["read", "create", "update", "delete", "query"] + ) + """Password Reset Policy Name. Only applies to AAD B2C Identity Provider.""" + client_library: Optional[str] = rest_field( + name="clientLibrary", visibility=["read", "create", "update", "delete", "query"] + ) + """The client library to be used in the developer portal. Only applies to AAD and AAD B2C Identity + Provider.""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[list[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IdentityProviderContract(ProxyResource): + """Identity Provider details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Identity Provider contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.IdentityProviderContractProperties + """ + + properties: Optional["_models.IdentityProviderContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Identity Provider contract properties.""" + + __flattened_items = [ + "type", + "signin_tenant", + "allowed_tenants", + "authority", + "signup_policy_name", + "signin_policy_name", + "profile_editing_policy_name", + "password_reset_policy_name", + "client_library", + "client_id", + "client_secret", + "certificate_id", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.IdentityProviderContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class IdentityProviderContractProperties(IdentityProviderBaseParameters): + """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active + Directory which can be used to enable access to the API Management service developer portal for + all users. + + :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", + "microsoft", "twitter", "aad", and "aadB2C". + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str + :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. Required. + :vartype client_id: str + :ivar client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :vartype client_secret: str + :ivar certificate_id: Certificate full resource ID used in external Identity Provider. + :vartype certificate_id: str + """ + + client_id: str = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """Client Id of the Application in the external Identity Provider. It is App ID for Facebook + login, Client ID for Google login, App ID for Microsoft. Required.""" + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + """Client secret of the Application in external Identity Provider, used to authenticate login + request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key + for Microsoft. This property will not be filled on 'GET' operations! Use '/listSecrets' POST + request to get the value.""" + certificate_id: Optional[str] = rest_field( + name="certificateId", visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate full resource ID used in external Identity Provider.""" + + @overload + def __init__( + self, + *, + client_id: str, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[list[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, + client_secret: Optional[str] = None, + certificate_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IdentityProviderCreateContract(ProxyResource): + """Identity Provider details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Identity Provider contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContractProperties + """ + + properties: Optional["_models.IdentityProviderCreateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Identity Provider contract properties.""" + + __flattened_items = [ + "type", + "signin_tenant", + "allowed_tenants", + "authority", + "signup_policy_name", + "signin_policy_name", + "profile_editing_policy_name", + "password_reset_policy_name", + "client_library", + "client_id", + "client_secret", + "certificate_id", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.IdentityProviderCreateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): + """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active + Directory which can be used to enable access to the API Management service developer portal for + all users. + + :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", + "microsoft", "twitter", "aad", and "aadB2C". + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str + :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. Required. + :vartype client_id: str + :ivar client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. Required. + :vartype client_secret: str + :ivar certificate_id: Certificate full resource ID used in external Identity Provider. + :vartype certificate_id: str + """ + + client_id: str = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """Client Id of the Application in the external Identity Provider. It is App ID for Facebook + login, Client ID for Google login, App ID for Microsoft. Required.""" + client_secret: str = rest_field(name="clientSecret", visibility=["read", "create", "update", "delete", "query"]) + """Client secret of the Application in external Identity Provider, used to authenticate login + request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key + for Microsoft. This property will not be filled on 'GET' operations! Use '/listSecrets' POST + request to get the value. Required.""" + certificate_id: Optional[str] = rest_field( + name="certificateId", visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate full resource ID used in external Identity Provider.""" + + @overload + def __init__( + self, + *, + client_id: str, + client_secret: str, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[list[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, + certificate_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IdentityProviderUpdateParameters(_Model): + """Parameters supplied to update Identity Provider. + + :ivar properties: Identity Provider update properties. + :vartype properties: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateProperties + """ + + properties: Optional["_models.IdentityProviderUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Identity Provider update properties.""" + + __flattened_items = [ + "type", + "signin_tenant", + "allowed_tenants", + "authority", + "signup_policy_name", + "signin_policy_name", + "profile_editing_policy_name", + "password_reset_policy_name", + "client_library", + "client_id", + "client_secret", + "certificate_id", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.IdentityProviderUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): + """Parameters supplied to the Update Identity Provider operation. + + :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", + "microsoft", "twitter", "aad", and "aadB2C". + :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :vartype signin_tenant: str + :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :vartype allowed_tenants: list[str] + :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :vartype authority: str + :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signup_policy_name: str + :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :vartype signin_policy_name: str + :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :vartype profile_editing_policy_name: str + :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :vartype password_reset_policy_name: str + :ivar client_library: The client library to be used in the developer portal. Only applies to + AAD and AAD B2C Identity Provider. + :vartype client_library: str + :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. + :vartype client_id: str + :ivar client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. + :vartype client_secret: str + :ivar certificate_id: Certificate full resource ID used in external Identity Provider. + :vartype certificate_id: str + """ + + client_id: Optional[str] = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """Client Id of the Application in the external Identity Provider. It is App ID for Facebook + login, Client ID for Google login, App ID for Microsoft.""" + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + """Client secret of the Application in external Identity Provider, used to authenticate login + request. For example, it is App Secret for Facebook login, API Key for Google login, Public Key + for Microsoft.""" + certificate_id: Optional[str] = rest_field( + name="certificateId", visibility=["read", "create", "update", "delete", "query"] + ) + """Certificate full resource ID used in external Identity Provider.""" + + @overload + def __init__( + self, + *, + type: Optional[Union[str, "_models.IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[list[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + client_library: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + certificate_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IssueAttachmentContract(ProxyResource): + """Issue Attachment Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Issue Attachment. + :vartype properties: ~azure.mgmt.apimanagement.models.IssueAttachmentContractProperties + """ + + properties: Optional["_models.IssueAttachmentContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Issue Attachment.""" + + __flattened_items = ["title", "content_format", "content"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.IssueAttachmentContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class IssueAttachmentContractProperties(_Model): + """Issue Attachment contract Properties. + + :ivar title: Filename by which the binary data will be saved. Required. + :vartype title: str + :ivar content_format: Either 'link' if content is provided via an HTTP link or the MIME type of + the Base64-encoded binary data provided in the 'content' property. Required. + :vartype content_format: str + :ivar content: An HTTP link or Base64-encoded binary data. Required. + :vartype content: str + """ + + title: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Filename by which the binary data will be saved. Required.""" + content_format: str = rest_field(name="contentFormat", visibility=["read", "create", "update", "delete", "query"]) + """Either 'link' if content is provided via an HTTP link or the MIME type of the Base64-encoded + binary data provided in the 'content' property. Required.""" + content: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An HTTP link or Base64-encoded binary data. Required.""" + + @overload + def __init__( + self, + *, + title: str, + content_format: str, + content: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IssueCommentContract(ProxyResource): + """Issue Comment Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Issue Comment. + :vartype properties: ~azure.mgmt.apimanagement.models.IssueCommentContractProperties + """ + + properties: Optional["_models.IssueCommentContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Issue Comment.""" + + __flattened_items = ["text", "created_date", "user_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.IssueCommentContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class IssueCommentContractProperties(_Model): + """Issue Comment contract Properties. + + :ivar text: Comment text. Required. + :vartype text: str + :ivar created_date: Date and time when the comment was created. + :vartype created_date: ~datetime.datetime + :ivar user_id: A resource identifier for the user who left the comment. Required. + :vartype user_id: str + """ + + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Comment text. Required.""" + created_date: Optional[datetime.datetime] = rest_field( + name="createdDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Date and time when the comment was created.""" + user_id: str = rest_field(name="userId", visibility=["read", "create", "update", "delete", "query"]) + """A resource identifier for the user who left the comment. Required.""" + + @overload + def __init__( + self, + *, + text: str, + user_id: str, + created_date: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IssueContract(ProxyResource): + """Issue Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Issue. + :vartype properties: ~azure.mgmt.apimanagement.models.IssueContractProperties + """ + + properties: Optional["_models.IssueContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Issue.""" + + __flattened_items = ["created_date", "state", "api_id", "title", "description", "user_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.IssueContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class IssueContractBaseProperties(_Model): + """Issue contract Base Properties. + + :ivar created_date: Date and time when the issue was created. + :vartype created_date: ~datetime.datetime + :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", + and "closed". + :vartype state: str or ~azure.mgmt.apimanagement.models.State + :ivar api_id: A resource identifier for the API the issue was created for. + :vartype api_id: str + """ + + created_date: Optional[datetime.datetime] = rest_field( + name="createdDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Date and time when the issue was created.""" + state: Optional[Union[str, "_models.State"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Status of the issue. Known values are: \"proposed\", \"open\", \"removed\", \"resolved\", and + \"closed\".""" + api_id: Optional[str] = rest_field(name="apiId", visibility=["read", "create", "update", "delete", "query"]) + """A resource identifier for the API the issue was created for.""" + + @overload + def __init__( + self, + *, + created_date: Optional[datetime.datetime] = None, + state: Optional[Union[str, "_models.State"]] = None, + api_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IssueContractProperties(IssueContractBaseProperties): + """Issue contract Properties. + + :ivar created_date: Date and time when the issue was created. + :vartype created_date: ~datetime.datetime + :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", + and "closed". + :vartype state: str or ~azure.mgmt.apimanagement.models.State + :ivar api_id: A resource identifier for the API the issue was created for. + :vartype api_id: str + :ivar title: The issue title. Required. + :vartype title: str + :ivar description: Text describing the issue. Required. + :vartype description: str + :ivar user_id: A resource identifier for the user created the issue. Required. + :vartype user_id: str + """ + + title: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The issue title. Required.""" + description: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Text describing the issue. Required.""" + user_id: str = rest_field(name="userId", visibility=["read", "create", "update", "delete", "query"]) + """A resource identifier for the user created the issue. Required.""" + + @overload + def __init__( + self, + *, + title: str, + description: str, + user_id: str, + created_date: Optional[datetime.datetime] = None, + state: Optional[Union[str, "_models.State"]] = None, + api_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IssueUpdateContract(_Model): + """Issue update Parameters. + + :ivar properties: Issue entity Update contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.IssueUpdateContractProperties + """ + + properties: Optional["_models.IssueUpdateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Issue entity Update contract properties.""" + + __flattened_items = ["created_date", "state", "api_id", "title", "description", "user_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.IssueUpdateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class IssueUpdateContractProperties(IssueContractBaseProperties): + """Issue contract Update Properties. + + :ivar created_date: Date and time when the issue was created. + :vartype created_date: ~datetime.datetime + :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", + and "closed". + :vartype state: str or ~azure.mgmt.apimanagement.models.State + :ivar api_id: A resource identifier for the API the issue was created for. + :vartype api_id: str + :ivar title: The issue title. + :vartype title: str + :ivar description: Text describing the issue. + :vartype description: str + :ivar user_id: A resource identifier for the user created the issue. + :vartype user_id: str + """ + + title: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The issue title.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Text describing the issue.""" + user_id: Optional[str] = rest_field(name="userId", visibility=["read", "create", "update", "delete", "query"]) + """A resource identifier for the user created the issue.""" + + @overload + def __init__( + self, + *, + created_date: Optional[datetime.datetime] = None, + state: Optional[Union[str, "_models.State"]] = None, + api_id: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + user_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class KeyVaultContractCreateProperties(_Model): + """Create keyVault contract details. + + :ivar secret_identifier: Key vault secret identifier for fetching secret. Providing a versioned + secret will prevent auto-refresh. This requires API Management service to be configured with + aka.ms/apimmsi. + :vartype secret_identifier: str + :ivar identity_client_id: Null for SystemAssignedIdentity or Client Id for UserAssignedIdentity + , which will be used to access key vault secret. + :vartype identity_client_id: str + """ + + secret_identifier: Optional[str] = rest_field( + name="secretIdentifier", visibility=["read", "create", "update", "delete", "query"] + ) + """Key vault secret identifier for fetching secret. Providing a versioned secret will prevent + auto-refresh. This requires API Management service to be configured with aka.ms/apimmsi.""" + identity_client_id: Optional[str] = rest_field( + name="identityClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """Null for SystemAssignedIdentity or Client Id for UserAssignedIdentity , which will be used to + access key vault secret.""" + + @overload + def __init__( + self, + *, + secret_identifier: Optional[str] = None, + identity_client_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class KeyVaultContractProperties(KeyVaultContractCreateProperties): + """KeyVault contract details. + + :ivar secret_identifier: Key vault secret identifier for fetching secret. Providing a versioned + secret will prevent auto-refresh. This requires API Management service to be configured with + aka.ms/apimmsi. + :vartype secret_identifier: str + :ivar identity_client_id: Null for SystemAssignedIdentity or Client Id for UserAssignedIdentity + , which will be used to access key vault secret. + :vartype identity_client_id: str + :ivar last_status: Last time sync and refresh status of secret from key vault. + :vartype last_status: + ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties + """ + + last_status: Optional["_models.KeyVaultLastAccessStatusContractProperties"] = rest_field( + name="lastStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Last time sync and refresh status of secret from key vault.""" + + @overload + def __init__( + self, + *, + secret_identifier: Optional[str] = None, + identity_client_id: Optional[str] = None, + last_status: Optional["_models.KeyVaultLastAccessStatusContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class KeyVaultLastAccessStatusContractProperties(_Model): # pylint: disable=name-too-long + """Issue contract Update Properties. + + :ivar code: Last status code for sync and refresh of secret from key vault. + :vartype code: str + :ivar message: Details of the error else empty. + :vartype message: str + :ivar time_stamp_utc: Last time secret was accessed. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype time_stamp_utc: ~datetime.datetime + """ + + code: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Last status code for sync and refresh of secret from key vault.""" + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Details of the error else empty.""" + time_stamp_utc: Optional[datetime.datetime] = rest_field( + name="timeStampUtc", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Last time secret was accessed. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + + @overload + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + time_stamp_utc: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LLMDiagnosticSettings(_Model): + """Diagnostic settings for Large Language Models. + + :ivar logs: Specifies whether default diagnostic should be enabled for Large Language Models or + not. Known values are: "enabled" and "disabled". + :vartype logs: str or ~azure.mgmt.apimanagement.models.LlmDiagnosticSettings + :ivar requests: Diagnostic settings for Large Language Models requests. + :vartype requests: ~azure.mgmt.apimanagement.models.LLMMessageDiagnosticSettings + :ivar responses: Diagnostic settings for Large Language Models responses. + :vartype responses: ~azure.mgmt.apimanagement.models.LLMMessageDiagnosticSettings + """ + + logs: Optional[Union[str, "_models.LlmDiagnosticSettings"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies whether default diagnostic should be enabled for Large Language Models or not. Known + values are: \"enabled\" and \"disabled\".""" + requests: Optional["_models.LLMMessageDiagnosticSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic settings for Large Language Models requests.""" + responses: Optional["_models.LLMMessageDiagnosticSettings"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic settings for Large Language Models responses.""" + + @overload + def __init__( + self, + *, + logs: Optional[Union[str, "_models.LlmDiagnosticSettings"]] = None, + requests: Optional["_models.LLMMessageDiagnosticSettings"] = None, + responses: Optional["_models.LLMMessageDiagnosticSettings"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LLMMessageDiagnosticSettings(_Model): + """Diagnostic settings for Large Language Models Messages. + + :ivar messages: Specifies which message should be logged. Currently there is only 'all' option. + "all" + :vartype messages: str or ~azure.mgmt.apimanagement.models.LlmMessageLogTypes + :ivar max_size_in_bytes: Maximum size of message to logs in bytes. The default size is 32KB. + :vartype max_size_in_bytes: int + """ + + messages: Optional[Union[str, "_models.LlmMessageLogTypes"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies which message should be logged. Currently there is only 'all' option. \"all\"""" + max_size_in_bytes: Optional[int] = rest_field( + name="maxSizeInBytes", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum size of message to logs in bytes. The default size is 32KB.""" + + @overload + def __init__( + self, + *, + messages: Optional[Union[str, "_models.LlmMessageLogTypes"]] = None, + max_size_in_bytes: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LoggerContract(ProxyResource): + """Logger details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Logger entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.LoggerContractProperties + """ + + properties: Optional["_models.LoggerContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Logger entity contract properties.""" + + __flattened_items = ["logger_type", "description", "credentials", "is_buffered", "resource_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.LoggerContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class LoggerContractProperties(_Model): + """The Logger entity in API Management represents an event sink that you can use to log API + Management events. Currently the Logger entity supports logging API Management events to Azure + Event Hubs. + + :ivar logger_type: Logger type. Required. Known values are: "azureEventHub", + "applicationInsights", and "azureMonitor". + :vartype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType + :ivar description: Logger description. + :vartype description: str + :ivar credentials: The name and SendRule connection string of the event hub for azureEventHub + logger. Instrumentation key for applicationInsights logger. + :vartype credentials: dict[str, str] + :ivar is_buffered: Whether records are buffered in the logger before publishing. Default is + assumed to be true. + :vartype is_buffered: bool + :ivar resource_id: Azure Resource Id of a log target (either Azure Event Hub resource or Azure + Application Insights resource). + :vartype resource_id: str + """ + + logger_type: Union[str, "_models.LoggerType"] = rest_field( + name="loggerType", visibility=["read", "create", "update", "delete", "query"] + ) + """Logger type. Required. Known values are: \"azureEventHub\", \"applicationInsights\", and + \"azureMonitor\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Logger description.""" + credentials: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name and SendRule connection string of the event hub for azureEventHub logger. + Instrumentation key for applicationInsights logger.""" + is_buffered: Optional[bool] = rest_field( + name="isBuffered", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether records are buffered in the logger before publishing. Default is assumed to be true.""" + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Azure Resource Id of a log target (either Azure Event Hub resource or Azure Application + Insights resource).""" + + @overload + def __init__( + self, + *, + logger_type: Union[str, "_models.LoggerType"], + description: Optional[str] = None, + credentials: Optional[dict[str, str]] = None, + is_buffered: Optional[bool] = None, + resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class LoggerUpdateContract(_Model): + """Logger update contract. + + :ivar properties: Logger entity update contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.LoggerUpdateParameters + """ + + properties: Optional["_models.LoggerUpdateParameters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Logger entity update contract properties.""" + + __flattened_items = ["logger_type", "description", "credentials", "is_buffered"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.LoggerUpdateParameters"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class LoggerUpdateParameters(_Model): + """Parameters supplied to the Update Logger operation. + + :ivar logger_type: Logger type. Known values are: "azureEventHub", "applicationInsights", and + "azureMonitor". + :vartype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType + :ivar description: Logger description. + :vartype description: str + :ivar credentials: Logger credentials. + :vartype credentials: dict[str, str] + :ivar is_buffered: Whether records are buffered in the logger before publishing. Default is + assumed to be true. + :vartype is_buffered: bool + """ + + logger_type: Optional[Union[str, "_models.LoggerType"]] = rest_field( + name="loggerType", visibility=["read", "create", "update", "delete", "query"] + ) + """Logger type. Known values are: \"azureEventHub\", \"applicationInsights\", and + \"azureMonitor\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Logger description.""" + credentials: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Logger credentials.""" + is_buffered: Optional[bool] = rest_field( + name="isBuffered", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether records are buffered in the logger before publishing. Default is assumed to be true.""" + + @overload + def __init__( + self, + *, + logger_type: Optional[Union[str, "_models.LoggerType"]] = None, + description: Optional[str] = None, + credentials: Optional[dict[str, str]] = None, + is_buffered: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ManagedServiceIdentity(_Model): + """Managed service identity (system assigned and/or user assigned identities). + + :ivar principal_id: The service principal ID of the system assigned identity. This property + will only be provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be + provided for a system assigned identity. + :vartype tenant_id: str + :ivar type: The type of managed identity assigned to this resource. Required. Known values are: + "None", "SystemAssigned", "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.apimanagement.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The identities assigned to this resource by the user. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.apimanagement.models.UserAssignedIdentity] + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The service principal ID of the system assigned identity. This property will only be provided + for a system assigned identity.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) + """The tenant ID of the system assigned identity. This property will only be provided for a system + assigned identity.""" + type: Union[str, "_models.ManagedServiceIdentityType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The type of managed identity assigned to this resource. Required. Known values are: \"None\", + \"SystemAssigned\", \"UserAssigned\", and \"SystemAssigned,UserAssigned\".""" + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = rest_field( + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] + ) + """The identities assigned to this resource by the user.""" + + @overload + def __init__( + self, + *, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[dict[str, "_models.UserAssignedIdentity"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class MigrateToStv2Contract(_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 + """ + + mode: Optional[Union[str, "_models.MigrateToStv2Mode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Mode of Migration to stv2. Default is PreserveIp. Known values are: \"PreserveIp\" and + \"NewIP\".""" + + @overload + def __init__( + self, + *, + mode: Optional[Union[str, "_models.MigrateToStv2Mode"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NamedValueContract(ProxyResource): + """NamedValue details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: NamedValue entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.NamedValueContractProperties + """ + + properties: Optional["_models.NamedValueContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """NamedValue entity contract properties.""" + + __flattened_items = ["tags", "secret", "display_name", "value", "key_vault", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.NamedValueContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class NamedValueEntityBaseParameters(_Model): + """NamedValue Entity Base Parameters set. + + :ivar tags: Optional tags that when provided can be used to filter the NamedValue list. + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :vartype secret: bool + """ + + tags: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional tags that when provided can be used to filter the NamedValue list.""" + secret: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Determines whether the value is a secret and should be encrypted or not. Default value is + false.""" + + @overload + def __init__( + self, + *, + tags: Optional[list[str]] = None, + secret: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NamedValueContractProperties(NamedValueEntityBaseParameters): + """NamedValue Contract properties. + + :ivar tags: Optional tags that when provided can be used to filter the NamedValue list. + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :vartype secret: bool + :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. Required. + :vartype display_name: str + :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :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 + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore + characters. Required.""" + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of + whitespace. This property will not be filled on 'GET' operations! Use '/listSecrets' POST + request to get the value.""" + key_vault: Optional["_models.KeyVaultContractProperties"] = rest_field( + name="keyVault", visibility=["read", "create", "update", "delete", "query"] + ) + """KeyVault location details of the namedValue.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The provisioning state.""" + + @overload + def __init__( + self, + *, + display_name: str, + tags: Optional[list[str]] = None, + secret: Optional[bool] = None, + value: Optional[str] = None, + key_vault: Optional["_models.KeyVaultContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NamedValueCreateContract(ProxyResource): + """NamedValue details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: NamedValue entity contract properties for PUT operation. + :vartype properties: ~azure.mgmt.apimanagement.models.NamedValueCreateContractProperties + """ + + properties: Optional["_models.NamedValueCreateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """NamedValue entity contract properties for PUT operation.""" + + __flattened_items = ["tags", "secret", "display_name", "value", "key_vault"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.NamedValueCreateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class NamedValueCreateContractProperties(NamedValueEntityBaseParameters): + """NamedValue Contract properties. + + :ivar tags: Optional tags that when provided can be used to filter the NamedValue list. + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :vartype secret: bool + :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. Required. + :vartype display_name: str + :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :vartype value: str + :ivar key_vault: KeyVault location details of the namedValue. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore + characters. Required.""" + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of + whitespace. This property will not be filled on 'GET' operations! Use '/listSecrets' POST + request to get the value.""" + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = rest_field( + name="keyVault", visibility=["read", "create", "update", "delete", "query"] + ) + """KeyVault location details of the namedValue.""" + + @overload + def __init__( + self, + *, + display_name: str, + tags: Optional[list[str]] = None, + secret: Optional[bool] = None, + value: Optional[str] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NamedValueSecretContract(_Model): + """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + + :ivar value: This is secret value of the NamedValue entity. + :vartype value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """This is secret value of the NamedValue entity.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NamedValueUpdateParameterProperties(NamedValueEntityBaseParameters): + """NamedValue Contract properties. + + :ivar tags: Optional tags that when provided can be used to filter the NamedValue list. + :vartype tags: list[str] + :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :vartype secret: bool + :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. + :vartype display_name: str + :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. + :vartype value: str + :ivar key_vault: KeyVault location details of the namedValue. + :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore + characters.""" + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of + whitespace.""" + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = rest_field( + name="keyVault", visibility=["read", "create", "update", "delete", "query"] + ) + """KeyVault location details of the namedValue.""" + + @overload + def __init__( + self, + *, + tags: Optional[list[str]] = None, + secret: Optional[bool] = None, + display_name: Optional[str] = None, + value: Optional[str] = None, + key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NamedValueUpdateParameters(_Model): + """NamedValue update Parameters. + + :ivar properties: NamedValue entity Update contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameterProperties + """ + + properties: Optional["_models.NamedValueUpdateParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """NamedValue entity Update contract properties.""" + + __flattened_items = ["tags", "secret", "display_name", "value", "key_vault"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.NamedValueUpdateParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class NetworkStatusContract(_Model): + """Network Status details. + + :ivar dns_servers: Gets the list of DNS servers IPV4 addresses. Required. + :vartype dns_servers: list[str] + :ivar connectivity_status: Gets the list of Connectivity Status to the Resources on which the + service depends upon. Required. + :vartype connectivity_status: list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] + """ + + dns_servers: list[str] = rest_field(name="dnsServers", visibility=["read", "create", "update", "delete", "query"]) + """Gets the list of DNS servers IPV4 addresses. Required.""" + connectivity_status: list["_models.ConnectivityStatusContract"] = rest_field( + name="connectivityStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Gets the list of Connectivity Status to the Resources on which the service depends upon. + Required.""" + + @overload + def __init__( + self, + *, + dns_servers: list[str], + connectivity_status: list["_models.ConnectivityStatusContract"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NetworkStatusContractByLocation(_Model): + """Network Status in the Location. + + :ivar location: Location of service. + :vartype location: str + :ivar network_status: Network status in Location. + :vartype network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract + """ + + location: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Location of service.""" + network_status: Optional["_models.NetworkStatusContract"] = rest_field( + name="networkStatus", visibility=["read", "create", "update", "delete", "query"] + ) + """Network status in Location.""" + + @overload + def __init__( + self, + *, + location: Optional[str] = None, + network_status: Optional["_models.NetworkStatusContract"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NotificationContract(ProxyResource): + """Notification details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Notification entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.NotificationContractProperties + """ + + properties: Optional["_models.NotificationContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Notification entity contract properties.""" + + __flattened_items = ["title", "description", "recipients"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.NotificationContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class NotificationContractProperties(_Model): + """Notification Contract properties. + + :ivar title: Title of the Notification. Required. + :vartype title: str + :ivar description: Description of the Notification. + :vartype description: str + :ivar recipients: Recipient Parameter values. + :vartype recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties + """ + + title: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Title of the Notification. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the Notification.""" + recipients: Optional["_models.RecipientsContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Recipient Parameter values.""" + + @overload + def __init__( + self, + *, + title: str, + description: Optional[str] = None, + recipients: Optional["_models.RecipientsContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OAuth2AuthenticationSettingsContract(_Model): + """API OAuth2 Authentication settings details. + + :ivar authorization_server_id: OAuth authorization server identifier. + :vartype authorization_server_id: str + :ivar scope: operations scope. + :vartype scope: str + """ + + authorization_server_id: Optional[str] = rest_field( + name="authorizationServerId", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth authorization server identifier.""" + scope: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """operations scope.""" + + @overload + def __init__( + self, + *, + authorization_server_id: Optional[str] = None, + scope: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OpenIdAuthenticationSettingsContract(_Model): + """API OAuth2 Authentication settings details. + + :ivar openid_provider_id: OAuth authorization server identifier. + :vartype openid_provider_id: str + :ivar bearer_token_sending_methods: How to send token to the server. + :vartype bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] + """ + + openid_provider_id: Optional[str] = rest_field( + name="openidProviderId", visibility=["read", "create", "update", "delete", "query"] + ) + """OAuth authorization server identifier.""" + bearer_token_sending_methods: Optional[list[Union[str, "_models.BearerTokenSendingMethods"]]] = rest_field( + name="bearerTokenSendingMethods", visibility=["read", "create", "update", "delete", "query"] + ) + """How to send token to the server.""" + + @overload + def __init__( + self, + *, + openid_provider_id: Optional[str] = None, + bearer_token_sending_methods: Optional[list[Union[str, "_models.BearerTokenSendingMethods"]]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OpenidConnectProviderContract(ProxyResource): + """OpenId Connect Provider details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: OpenId Connect Provider contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContractProperties + """ + + properties: Optional["_models.OpenidConnectProviderContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """OpenId Connect Provider contract properties.""" + + __flattened_items = [ + "display_name", + "description", + "metadata_endpoint", + "client_id", + "client_secret", + "use_in_test_console", + "use_in_api_documentation", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OpenidConnectProviderContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OpenidConnectProviderContractProperties(_Model): + """OpenID Connect Providers Contract. + + :ivar display_name: User-friendly OpenID Connect Provider name. Required. + :vartype display_name: str + :ivar description: User-friendly description of OpenID Connect Provider. + :vartype description: str + :ivar metadata_endpoint: Metadata endpoint URI. Required. + :vartype metadata_endpoint: str + :ivar client_id: Client ID of developer console which is the client application. Required. + :vartype client_id: str + :ivar client_secret: Client Secret of developer console which is the client application. + :vartype client_secret: str + :ivar use_in_test_console: If true, the Open ID Connect provider may be used in the developer + portal test console. True by default if no value is provided. + :vartype use_in_test_console: bool + :ivar use_in_api_documentation: If true, the Open ID Connect provider will be used in the API + documentation in the developer portal. False by default if no value is provided. + :vartype use_in_api_documentation: bool + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """User-friendly OpenID Connect Provider name. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """User-friendly description of OpenID Connect Provider.""" + metadata_endpoint: str = rest_field( + name="metadataEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Metadata endpoint URI. Required.""" + client_id: str = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """Client ID of developer console which is the client application. Required.""" + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + """Client Secret of developer console which is the client application.""" + use_in_test_console: Optional[bool] = rest_field( + name="useInTestConsole", visibility=["read", "create", "update", "delete", "query"] + ) + """If true, the Open ID Connect provider may be used in the developer portal test console. True by + default if no value is provided.""" + use_in_api_documentation: Optional[bool] = rest_field( + name="useInApiDocumentation", visibility=["read", "create", "update", "delete", "query"] + ) + """If true, the Open ID Connect provider will be used in the API documentation in the developer + portal. False by default if no value is provided.""" + + @overload + def __init__( + self, + *, + display_name: str, + metadata_endpoint: str, + client_id: str, + description: Optional[str] = None, + client_secret: Optional[str] = None, + use_in_test_console: Optional[bool] = None, + use_in_api_documentation: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OpenidConnectProviderUpdateContract(_Model): + """Parameters supplied to the Update OpenID Connect Provider operation. + + :ivar properties: OpenId Connect Provider Update contract properties. + :vartype properties: + ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContractProperties + """ + + properties: Optional["_models.OpenidConnectProviderUpdateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """OpenId Connect Provider Update contract properties.""" + + __flattened_items = [ + "display_name", + "description", + "metadata_endpoint", + "client_id", + "client_secret", + "use_in_test_console", + "use_in_api_documentation", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OpenidConnectProviderUpdateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OpenidConnectProviderUpdateContractProperties(_Model): # pylint: disable=name-too-long + """Parameters supplied to the Update OpenID Connect Provider operation. + + :ivar display_name: User-friendly OpenID Connect Provider name. + :vartype display_name: str + :ivar description: User-friendly description of OpenID Connect Provider. + :vartype description: str + :ivar metadata_endpoint: Metadata endpoint URI. + :vartype metadata_endpoint: str + :ivar client_id: Client ID of developer console which is the client application. + :vartype client_id: str + :ivar client_secret: Client Secret of developer console which is the client application. + :vartype client_secret: str + :ivar use_in_test_console: If true, the Open ID Connect provider may be used in the developer + portal test console. True by default if no value is provided. + :vartype use_in_test_console: bool + :ivar use_in_api_documentation: If true, the Open ID Connect provider will be used in the API + documentation in the developer portal. False by default if no value is provided. + :vartype use_in_api_documentation: bool + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """User-friendly OpenID Connect Provider name.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """User-friendly description of OpenID Connect Provider.""" + metadata_endpoint: Optional[str] = rest_field( + name="metadataEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """Metadata endpoint URI.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """Client ID of developer console which is the client application.""" + client_secret: Optional[str] = rest_field( + name="clientSecret", visibility=["read", "create", "update", "delete", "query"] + ) + """Client Secret of developer console which is the client application.""" + use_in_test_console: Optional[bool] = rest_field( + name="useInTestConsole", visibility=["read", "create", "update", "delete", "query"] + ) + """If true, the Open ID Connect provider may be used in the developer portal test console. True by + default if no value is provided.""" + use_in_api_documentation: Optional[bool] = rest_field( + name="useInApiDocumentation", visibility=["read", "create", "update", "delete", "query"] + ) + """If true, the Open ID Connect provider will be used in the API documentation in the developer + portal. False by default if no value is provided.""" + + @overload + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata_endpoint: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + use_in_test_console: Optional[bool] = None, + use_in_api_documentation: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """REST API operation. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that describes the operation. + :vartype display: ~azure.mgmt.apimanagement.models.OperationDisplay + :ivar origin: The operation origin. + :vartype origin: str + :ivar properties: The operation properties. + :vartype properties: any + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation name: {provider}/{resource}/{operation}.""" + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object that describes the operation.""" + origin: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The operation origin.""" + properties: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The operation properties.""" + + __flattened_items = [""] + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + properties: Optional[Any] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OperationContract(ProxyResource): + """API Operation details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Operation Contract. + :vartype properties: ~azure.mgmt.apimanagement.models.OperationContractProperties + """ + + properties: Optional["_models.OperationContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Operation Contract.""" + + __flattened_items = [ + "template_parameters", + "description", + "request", + "responses", + "policies", + "display_name", + "method", + "url_template", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OperationContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OperationEntityBaseContract(_Model): + """API Operation Entity Base Contract details. + + :ivar template_parameters: Collection of URL template parameters. + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar description: Description of the operation. May include HTML formatting tags. + :vartype description: str + :ivar request: An entity containing request details. + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract + :ivar responses: Array of Operation responses. + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :ivar policies: Operation Policies. + :vartype policies: str + """ + + template_parameters: Optional[list["_models.ParameterContract"]] = rest_field( + name="templateParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of URL template parameters.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the operation. May include HTML formatting tags.""" + request: Optional["_models.RequestContract"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """An entity containing request details.""" + responses: Optional[list["_models.ResponseContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Array of Operation responses.""" + policies: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation Policies.""" + + @overload + def __init__( + self, + *, + template_parameters: Optional[list["_models.ParameterContract"]] = None, + description: Optional[str] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[list["_models.ResponseContract"]] = None, + policies: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationContractProperties(OperationEntityBaseContract): + """Operation Contract Properties. + + :ivar template_parameters: Collection of URL template parameters. + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar description: Description of the operation. May include HTML formatting tags. + :vartype description: str + :ivar request: An entity containing request details. + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract + :ivar responses: Array of Operation responses. + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :ivar policies: Operation Policies. + :vartype policies: str + :ivar display_name: Operation Name. Required. + :vartype display_name: str + :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. Required. + :vartype method: str + :ivar url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. Required. + :vartype url_template: str + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Operation Name. Required.""" + method: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only + them. Required.""" + url_template: str = rest_field(name="urlTemplate", visibility=["read", "create", "update", "delete", "query"]) + """Relative URL template identifying the target resource for this operation. May include + parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. Required.""" + + @overload + def __init__( + self, + *, + display_name: str, + method: str, + url_template: str, + template_parameters: Optional[list["_models.ParameterContract"]] = None, + description: Optional[str] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[list["_models.ResponseContract"]] = None, + policies: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationDisplay(_Model): + """The object that describes the operation. + + :ivar provider: Friendly name of the resource provider. + :vartype provider: str + :ivar operation: Operation type: read, write, delete, listKeys/action, etc. + :vartype operation: str + :ivar resource: Resource type on which the operation is performed. + :vartype resource: str + :ivar description: Friendly name of the operation. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Friendly name of the resource provider.""" + operation: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation type: read, write, delete, listKeys/action, etc.""" + resource: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource type on which the operation is performed.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Friendly name of the operation.""" + + @overload + def __init__( + self, + *, + provider: Optional[str] = None, + operation: Optional[str] = None, + resource: Optional[str] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationResultContract(ProxyResource): + """Long Running Git Operation Results. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Operation Contract. + :vartype properties: ~azure.mgmt.apimanagement.models.OperationResultContractProperties + """ + + properties: Optional["_models.OperationResultContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Operation Contract.""" + + __flattened_items = ["id", "status", "started", "updated", "result_info", "error", "action_log"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OperationResultContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OperationResultContractProperties(_Model): + """Operation Result. + + :ivar id: Operation result identifier. + :vartype id: str + :ivar status: Status of an async operation. Known values are: "Started", "InProgress", + "Succeeded", and "Failed". + :vartype status: str or ~azure.mgmt.apimanagement.models.AsyncOperationStatus + :ivar started: Start time of an async operation. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype started: ~datetime.datetime + :ivar updated: Last update time of an async operation. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype updated: ~datetime.datetime + :ivar result_info: Optional result info. + :vartype result_info: str + :ivar error: Error Body Contract. + :vartype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody + :ivar action_log: This property if only provided as part of the TenantConfiguration_Validate + operation. It contains the log the entities which will be updated/created/deleted as part of + the TenantConfiguration_Deploy operation. + :vartype action_log: list[~azure.mgmt.apimanagement.models.OperationResultLogItemContract] + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation result identifier.""" + status: Optional[Union[str, "_models.AsyncOperationStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Status of an async operation. Known values are: \"Started\", \"InProgress\", \"Succeeded\", and + \"Failed\".""" + started: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Start time of an async operation. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + updated: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Last update time of an async operation. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + result_info: Optional[str] = rest_field( + name="resultInfo", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional result info.""" + error: Optional["_models.ErrorResponseBody"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Error Body Contract.""" + action_log: Optional[list["_models.OperationResultLogItemContract"]] = rest_field( + name="actionLog", visibility=["read"] + ) + """This property if only provided as part of the TenantConfiguration_Validate operation. It + contains the log the entities which will be updated/created/deleted as part of the + TenantConfiguration_Deploy operation.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + status: Optional[Union[str, "_models.AsyncOperationStatus"]] = None, + started: Optional[datetime.datetime] = None, + updated: Optional[datetime.datetime] = None, + result_info: Optional[str] = None, + error: Optional["_models.ErrorResponseBody"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationResultLogItemContract(_Model): + """Log of the entity being created, updated or deleted. + + :ivar object_type: The type of entity contract. + :vartype object_type: str + :ivar action: Action like create/update/delete. + :vartype action: str + :ivar object_key: Identifier of the entity being created/updated/deleted. + :vartype object_key: str + """ + + object_type: Optional[str] = rest_field( + name="objectType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of entity contract.""" + action: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Action like create/update/delete.""" + object_key: Optional[str] = rest_field(name="objectKey", visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the entity being created/updated/deleted.""" + + @overload + def __init__( + self, + *, + object_type: Optional[str] = None, + action: Optional[str] = None, + object_key: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationStatusResult(_Model): + """The current status of an async operation. + + :ivar id: Fully qualified ID for the async operation. + :vartype 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 + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Fully qualified ID for the async operation.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name of the async operation.""" + status: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation status. Required.""" + percent_complete: Optional[float] = rest_field( + name="percentComplete", visibility=["read", "create", "update", "delete", "query"] + ) + """Percent of the operation that is complete.""" + start_time: Optional[datetime.datetime] = rest_field( + name="startTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The start time of the operation.""" + end_time: Optional[datetime.datetime] = rest_field( + name="endTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The end time of the operation.""" + operations: Optional[list["_models.OperationStatusResult"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The operations list.""" + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """If present, details of the operation error.""" + + @overload + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationTagResourceContractProperties(_Model): + """Operation Entity contract Properties. + + :ivar id: Identifier of the operation in form /operations/{operationId}. + :vartype id: str + :ivar name: Operation name. + :vartype name: str + :ivar api_name: API Name. + :vartype api_name: str + :ivar api_revision: API Revision. + :vartype api_revision: str + :ivar api_version: API Version. + :vartype api_version: str + :ivar description: Operation Description. + :vartype description: str + :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. + :vartype method: str + :ivar url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :vartype url_template: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the operation in form /operations/{operationId}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """Operation name.""" + api_name: Optional[str] = rest_field(name="apiName", visibility=["read"]) + """API Name.""" + api_revision: Optional[str] = rest_field(name="apiRevision", visibility=["read"]) + """API Revision.""" + api_version: Optional[str] = rest_field(name="apiVersion", visibility=["read"]) + """API Version.""" + description: Optional[str] = rest_field(visibility=["read"]) + """Operation Description.""" + method: Optional[str] = rest_field(visibility=["read"]) + """A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only + them.""" + url_template: Optional[str] = rest_field(name="urlTemplate", visibility=["read"]) + """Relative URL template identifying the target resource for this operation. May include + parameters. Example: /customers/{cid}/orders/{oid}/?date={date}.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationUpdateContract(_Model): + """API Operation Update Contract details. + + :ivar properties: Properties of the API Operation entity that can be updated. + :vartype properties: ~azure.mgmt.apimanagement.models.OperationUpdateContractProperties + """ + + properties: Optional["_models.OperationUpdateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API Operation entity that can be updated.""" + + __flattened_items = [ + "template_parameters", + "description", + "request", + "responses", + "policies", + "display_name", + "method", + "url_template", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.OperationUpdateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class OperationUpdateContractProperties(OperationEntityBaseContract): + """Operation Update Contract Properties. + + :ivar template_parameters: Collection of URL template parameters. + :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar description: Description of the operation. May include HTML formatting tags. + :vartype description: str + :ivar request: An entity containing request details. + :vartype request: ~azure.mgmt.apimanagement.models.RequestContract + :ivar responses: Array of Operation responses. + :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :ivar policies: Operation Policies. + :vartype policies: str + :ivar display_name: Operation Name. + :vartype display_name: str + :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. + :vartype method: str + :ivar url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :vartype url_template: str + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Operation Name.""" + method: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only + them.""" + url_template: Optional[str] = rest_field( + name="urlTemplate", visibility=["read", "create", "update", "delete", "query"] + ) + """Relative URL template identifying the target resource for this operation. May include + parameters. Example: /customers/{cid}/orders/{oid}/?date={date}.""" + + @overload + def __init__( + self, + *, + template_parameters: Optional[list["_models.ParameterContract"]] = None, + description: Optional[str] = None, + request: Optional["_models.RequestContract"] = None, + responses: Optional[list["_models.ResponseContract"]] = None, + policies: Optional[str] = None, + display_name: Optional[str] = None, + method: Optional[str] = None, + url_template: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OutboundEnvironmentEndpoint(_Model): + """Endpoints accessed for a common purpose that the Api Management Service requires outbound + network access to. + + :ivar category: The type of service accessed by the Api Management Service, e.g., Azure + Storage, Azure SQL Database, and Azure Active Directory. + :vartype category: str + :ivar endpoints: The endpoints that the Api Management Service reaches the service at. + :vartype endpoints: list[~azure.mgmt.apimanagement.models.EndpointDependency] + """ + + category: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of service accessed by the Api Management Service, e.g., Azure Storage, Azure SQL + Database, and Azure Active Directory.""" + endpoints: Optional[list["_models.EndpointDependency"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The endpoints that the Api Management Service reaches the service at.""" + + @overload + def __init__( + self, + *, + category: Optional[str] = None, + endpoints: Optional[list["_models.EndpointDependency"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OutboundEnvironmentEndpointList(_Model): + """Collection of Outbound Environment Endpoints. + + :ivar value: Collection of resources. Required. + :vartype value: list[~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpoint] + :ivar next_link: Link to next page of resources. + :vartype next_link: str + """ + + value: list["_models.OutboundEnvironmentEndpoint"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of resources. Required.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read"]) + """Link to next page of resources.""" + + @overload + def __init__( + self, + *, + value: list["_models.OutboundEnvironmentEndpoint"], + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ParameterContract(_Model): + """Operation parameters details. + + :ivar name: Parameter name. Required. + :vartype name: str + :ivar description: Parameter description. + :vartype description: str + :ivar type: Parameter type. Required. + :vartype type: str + :ivar default_value: Default parameter value. + :vartype default_value: str + :ivar required: Specifies whether parameter is required or not. + :vartype required: bool + :ivar values_property: Parameter values. + :vartype values_property: list[str] + :ivar schema_id: Schema identifier. + :vartype schema_id: str + :ivar type_name: Type name defined by the schema. + :vartype type_name: str + :ivar examples: Exampled defined for the parameter. + :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Parameter name. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Parameter description.""" + type: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Parameter type. Required.""" + default_value: Optional[str] = rest_field( + name="defaultValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Default parameter value.""" + required: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Specifies whether parameter is required or not.""" + values_property: Optional[list[str]] = rest_field( + name="values", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="values" + ) + """Parameter values.""" + schema_id: Optional[str] = rest_field(name="schemaId", visibility=["read", "create", "update", "delete", "query"]) + """Schema identifier.""" + type_name: Optional[str] = rest_field(name="typeName", visibility=["read", "create", "update", "delete", "query"]) + """Type name defined by the schema.""" + examples: Optional[dict[str, "_models.ParameterExampleContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Exampled defined for the parameter.""" + + @overload + def __init__( + self, + *, + name: str, + type: str, + description: Optional[str] = None, + default_value: Optional[str] = None, + required: Optional[bool] = None, + values_property: Optional[list[str]] = None, + schema_id: Optional[str] = None, + type_name: Optional[str] = None, + examples: Optional[dict[str, "_models.ParameterExampleContract"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ParameterExampleContract(_Model): + """Parameter example. + + :ivar summary: Short description for the example. + :vartype summary: str + :ivar description: Long description for the example. + :vartype description: str + :ivar value: Example value. May be a primitive value, or an object. + :vartype value: any + :ivar external_value: A URL that points to the literal example. + :vartype external_value: str + """ + + summary: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Short description for the example.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Long description for the example.""" + value: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Example value. May be a primitive value, or an object.""" + external_value: Optional[str] = rest_field( + name="externalValue", visibility=["read", "create", "update", "delete", "query"] + ) + """A URL that points to the literal example.""" + + @overload + def __init__( + self, + *, + summary: Optional[str] = None, + description: Optional[str] = None, + value: Optional[Any] = None, + external_value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PipelineDiagnosticSettings(_Model): + """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + + :ivar request: Diagnostic settings for request. + :vartype request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic + :ivar response: Diagnostic settings for response. + :vartype response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic + """ + + request: Optional["_models.HttpMessageDiagnostic"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic settings for request.""" + response: Optional["_models.HttpMessageDiagnostic"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Diagnostic settings for response.""" + + @overload + def __init__( + self, + *, + request: Optional["_models.HttpMessageDiagnostic"] = None, + response: Optional["_models.HttpMessageDiagnostic"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyCollection(_Model): + """The response of the list policy operation. + + :ivar value: Policy Contract value. + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyContract] + :ivar count: Total record count number. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + value: Optional[list["_models.PolicyContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Policy Contract value.""" + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Total record count number.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """Next page link if any.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.PolicyContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyContract(ProxyResource): + """Policy Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Policy. + :vartype properties: ~azure.mgmt.apimanagement.models.PolicyContractProperties + """ + + properties: Optional["_models.PolicyContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Policy.""" + + __flattened_items = ["value", "format"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PolicyContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PolicyContractProperties(_Model): + """Policy contract Properties. + + :ivar value: Contents of the Policy as defined by the format. Required. + :vartype value: str + :ivar format: Format of the policyContent. Known values are: "xml", "xml-link", "rawxml", and + "rawxml-link". + :vartype format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + """ + + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Contents of the Policy as defined by the format. Required.""" + format: Optional[Union[str, "_models.PolicyContentFormat"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Format of the policyContent. Known values are: \"xml\", \"xml-link\", \"rawxml\", and + \"rawxml-link\".""" + + @overload + def __init__( + self, + *, + value: str, + format: Optional[Union[str, "_models.PolicyContentFormat"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyDescriptionCollection(_Model): + """Descriptions of API Management policies. + + :ivar value: Descriptions of API Management policies. + :vartype value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] + :ivar count: Total record count number. + :vartype count: int + """ + + value: Optional[list["_models.PolicyDescriptionContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Descriptions of API Management policies.""" + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Total record count number.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.PolicyDescriptionContract"]] = None, + count: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyDescriptionContract(ProxyResource): + """Policy description details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Policy description contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.PolicyDescriptionContractProperties + """ + + properties: Optional["_models.PolicyDescriptionContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Policy description contract properties.""" + + __flattened_items = ["description", "scope"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PolicyDescriptionContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PolicyDescriptionContractProperties(_Model): + """Policy description properties. + + :ivar description: Policy description. + :vartype description: str + :ivar scope: Binary OR value of the Snippet scope. + :vartype scope: int + """ + + description: Optional[str] = rest_field(visibility=["read"]) + """Policy description.""" + scope: Optional[int] = rest_field(visibility=["read"]) + """Binary OR value of the Snippet scope.""" + + +class PolicyFragmentContract(ProxyResource): + """Policy fragment contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Policy Fragment. + :vartype properties: ~azure.mgmt.apimanagement.models.PolicyFragmentContractProperties + """ + + properties: Optional["_models.PolicyFragmentContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Policy Fragment.""" + + __flattened_items = ["value", "description", "format", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PolicyFragmentContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PolicyFragmentContractProperties(_Model): + """Policy fragment contract properties. + + :ivar value: Contents of the policy fragment. Required. + :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 + """ + + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Contents of the policy fragment. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Policy fragment description.""" + format: Optional[Union[str, "_models.PolicyFragmentContentFormat"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Format of the policy fragment content. Known values are: \"xml\" and \"rawxml\".""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The provisioning state.""" + + @overload + def __init__( + self, + *, + value: str, + description: Optional[str] = None, + format: Optional[Union[str, "_models.PolicyFragmentContentFormat"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyRestrictionContract(ProxyResource): + """Policy restriction contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Policy Restriction. + :vartype properties: ~azure.mgmt.apimanagement.models.PolicyRestrictionContractProperties + """ + + properties: Optional["_models.PolicyRestrictionContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Policy Restriction.""" + + __flattened_items = ["scope", "require_base"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PolicyRestrictionContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PolicyRestrictionContractProperties(_Model): + """Policy restrictions contract properties. + + :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 + """ + + scope: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Path to the policy document.""" + require_base: Optional[Union[str, "_models.PolicyRestrictionRequireBase"]] = rest_field( + name="requireBase", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if base policy should be enforced for the policy document. Known values are: \"true\" + and \"false\".""" + + @overload + def __init__( + self, + *, + scope: Optional[str] = None, + require_base: Optional[Union[str, "_models.PolicyRestrictionRequireBase"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyRestrictionUpdateContract(_Model): + """Policy restriction contract details. + + :ivar properties: Properties of the Policy Restriction. + :vartype properties: ~azure.mgmt.apimanagement.models.PolicyRestrictionContractProperties + """ + + properties: Optional["_models.PolicyRestrictionContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Policy Restriction.""" + + __flattened_items = ["scope", "require_base"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PolicyRestrictionContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PortalConfigContract(ProxyResource): + """The developer portal configuration contract. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: The developer portal configuration contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.PortalConfigProperties + """ + + properties: Optional["_models.PortalConfigProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The developer portal configuration contract properties.""" + + __flattened_items = ["enable_basic_auth", "signin", "signup", "delegation", "cors", "csp"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PortalConfigProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PortalConfigCorsProperties(_Model): + """The developer portal Cross-Origin Resource Sharing (CORS) settings. + + :ivar allowed_origins: Allowed origins, e.g. ``https://trusted.com``. + :vartype allowed_origins: list[str] + """ + + allowed_origins: Optional[list[str]] = rest_field( + name="allowedOrigins", visibility=["read", "create", "update", "delete", "query"] + ) + """Allowed origins, e.g. ``https://trusted.com``.""" + + @overload + def __init__( + self, + *, + allowed_origins: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalConfigCspProperties(_Model): + """The developer portal Content Security Policy (CSP) settings. + + :ivar mode: The mode of the developer portal Content Security Policy (CSP). Known values are: + "enabled", "disabled", and "reportOnly". + :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``, ``https://``. + :vartype allowed_sources: list[str] + """ + + mode: Optional[Union[str, "_models.PortalSettingsCspMode"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The mode of the developer portal Content Security Policy (CSP). Known values are: \"enabled\", + \"disabled\", and \"reportOnly\".""" + report_uri: Optional[list[str]] = rest_field( + name="reportUri", visibility=["read", "create", "update", "delete", "query"] + ) + """The URLs used by the browser to report CSP violations.""" + allowed_sources: Optional[list[str]] = rest_field( + name="allowedSources", visibility=["read", "create", "update", "delete", "query"] + ) + """Allowed sources, e.g. ``*.trusted.com``, ``trusted.com``, ``https://``.""" + + @overload + def __init__( + self, + *, + mode: Optional[Union[str, "_models.PortalSettingsCspMode"]] = None, + report_uri: Optional[list[str]] = None, + allowed_sources: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalConfigDelegationProperties(_Model): + """PortalConfigDelegationProperties. + + :ivar delegate_registration: Enable or disable delegation for user registration. + :vartype delegate_registration: bool + :ivar delegate_subscription: Enable or disable delegation for product subscriptions. + :vartype delegate_subscription: bool + :ivar delegation_url: A delegation endpoint URL. + :vartype delegation_url: str + :ivar validation_key: A base64-encoded validation key to ensure requests originate from Azure + API Management service. + :vartype validation_key: str + """ + + delegate_registration: Optional[bool] = rest_field( + name="delegateRegistration", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable or disable delegation for user registration.""" + delegate_subscription: Optional[bool] = rest_field( + name="delegateSubscription", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable or disable delegation for product subscriptions.""" + delegation_url: Optional[str] = rest_field( + name="delegationUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """A delegation endpoint URL.""" + validation_key: Optional[str] = rest_field( + name="validationKey", visibility=["read", "create", "update", "delete", "query"] + ) + """A base64-encoded validation key to ensure requests originate from Azure API Management service.""" + + @overload + def __init__( + self, + *, + delegate_registration: Optional[bool] = None, + delegate_subscription: Optional[bool] = None, + delegation_url: Optional[str] = None, + validation_key: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalConfigProperties(_Model): + """The developer portal configuration contract properties. + + :ivar enable_basic_auth: Enable or disable Basic authentication method. + :vartype enable_basic_auth: bool + :ivar signin: + :vartype signin: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignin + :ivar signup: + :vartype signup: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignup + :ivar delegation: The developer portal delegation settings. + :vartype delegation: ~azure.mgmt.apimanagement.models.PortalConfigDelegationProperties + :ivar cors: The developer portal Cross-Origin Resource Sharing (CORS) settings. + :vartype cors: ~azure.mgmt.apimanagement.models.PortalConfigCorsProperties + :ivar csp: The developer portal Content Security Policy (CSP) settings. + :vartype csp: ~azure.mgmt.apimanagement.models.PortalConfigCspProperties + """ + + enable_basic_auth: Optional[bool] = rest_field( + name="enableBasicAuth", visibility=["read", "create", "update", "delete", "query"] + ) + """Enable or disable Basic authentication method.""" + signin: Optional["_models.PortalConfigPropertiesSignin"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + signup: Optional["_models.PortalConfigPropertiesSignup"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + delegation: Optional["_models.PortalConfigDelegationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The developer portal delegation settings.""" + cors: Optional["_models.PortalConfigCorsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The developer portal Cross-Origin Resource Sharing (CORS) settings.""" + csp: Optional["_models.PortalConfigCspProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The developer portal Content Security Policy (CSP) settings.""" + + @overload + def __init__( + self, + *, + enable_basic_auth: Optional[bool] = None, + signin: Optional["_models.PortalConfigPropertiesSignin"] = None, + signup: Optional["_models.PortalConfigPropertiesSignup"] = None, + delegation: Optional["_models.PortalConfigDelegationProperties"] = None, + cors: Optional["_models.PortalConfigCorsProperties"] = None, + csp: Optional["_models.PortalConfigCspProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalConfigPropertiesSignin(_Model): + """PortalConfigPropertiesSignin. + + :ivar require: Redirect anonymous users to the sign-in page. + :vartype require: bool + """ + + require: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Redirect anonymous users to the sign-in page.""" + + @overload + def __init__( + self, + *, + require: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalConfigPropertiesSignup(_Model): + """PortalConfigPropertiesSignup. + + :ivar terms_of_service: Terms of service settings. + :vartype terms_of_service: + ~azure.mgmt.apimanagement.models.PortalConfigTermsOfServiceProperties + """ + + terms_of_service: Optional["_models.PortalConfigTermsOfServiceProperties"] = rest_field( + name="termsOfService", visibility=["read", "create", "update", "delete", "query"] + ) + """Terms of service settings.""" + + @overload + def __init__( + self, + *, + terms_of_service: Optional["_models.PortalConfigTermsOfServiceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalConfigTermsOfServiceProperties(_Model): + """Terms of service contract properties. + + :ivar text: A terms of service text. + :vartype text: str + :ivar require_consent: Ask user for consent to the terms of service. + :vartype require_consent: bool + """ + + text: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A terms of service text.""" + require_consent: Optional[bool] = rest_field( + name="requireConsent", visibility=["read", "create", "update", "delete", "query"] + ) + """Ask user for consent to the terms of service.""" + + @overload + def __init__( + self, + *, + text: Optional[str] = None, + require_consent: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalDelegationSettings(ProxyResource): + """Delegation settings for a developer portal. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Delegation settings contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.PortalDelegationSettingsProperties + """ + + properties: Optional["_models.PortalDelegationSettingsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Delegation settings contract properties.""" + + __flattened_items = ["url", "validation_key", "subscriptions", "user_registration"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PortalDelegationSettingsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PortalDelegationSettingsProperties(_Model): + """Delegation settings contract properties. + + :ivar url: A delegation Url. + :vartype url: str + :ivar validation_key: A base64-encoded validation key to validate, that a request is coming + from Azure API Management. + :vartype validation_key: str + :ivar subscriptions: Subscriptions delegation settings. + :vartype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties + :ivar user_registration: User registration delegation settings. + :vartype user_registration: + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties + """ + + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A delegation Url.""" + validation_key: Optional[str] = rest_field( + name="validationKey", visibility=["read", "create", "update", "delete", "query"] + ) + """A base64-encoded validation key to validate, that a request is coming from Azure API + Management.""" + subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Subscriptions delegation settings.""" + user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = rest_field( + name="userRegistration", visibility=["read", "create", "update", "delete", "query"] + ) + """User registration delegation settings.""" + + @overload + def __init__( + self, + *, + url: Optional[str] = None, + validation_key: Optional[str] = None, + subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = None, + user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalRevisionContract(ProxyResource): + """Portal Revision's contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the portal revisions. + :vartype properties: ~azure.mgmt.apimanagement.models.PortalRevisionContractProperties + """ + + properties: Optional["_models.PortalRevisionContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the portal revisions.""" + + __flattened_items = [ + "description", + "status_details", + "status", + "is_current", + "created_date_time", + "updated_date_time", + "provisioning_state", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PortalRevisionContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PortalRevisionContractProperties(_Model): + """PortalRevisionContractProperties. + + :ivar description: Portal revision description. + :vartype description: str + :ivar status_details: Portal revision publishing status details. + :vartype status_details: str + :ivar status: Status of the portal's revision. Known values are: "pending", "publishing", + "completed", and "failed". + :vartype status: str or ~azure.mgmt.apimanagement.models.PortalRevisionStatus + :ivar is_current: Indicates if the portal's revision is public. + :vartype is_current: bool + :ivar created_date_time: Portal's revision creation date and time. + :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 + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Portal revision description.""" + status_details: Optional[str] = rest_field(name="statusDetails", visibility=["read"]) + """Portal revision publishing status details.""" + status: Optional[Union[str, "_models.PortalRevisionStatus"]] = rest_field(visibility=["read"]) + """Status of the portal's revision. Known values are: \"pending\", \"publishing\", \"completed\", + and \"failed\".""" + is_current: Optional[bool] = rest_field( + name="isCurrent", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates if the portal's revision is public.""" + created_date_time: Optional[datetime.datetime] = rest_field( + name="createdDateTime", visibility=["read"], format="rfc3339" + ) + """Portal's revision creation date and time.""" + updated_date_time: Optional[datetime.datetime] = rest_field( + name="updatedDateTime", visibility=["read"], format="rfc3339" + ) + """Last updated date and time.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The provisioning state.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + is_current: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalSettingsCollection(_Model): + """Descriptions of API Management policies. + + :ivar value: Descriptions of API Management policies. + :vartype value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] + :ivar count: Total record count number. + :vartype count: int + """ + + value: Optional[list["_models.PortalSettingsContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Descriptions of API Management policies.""" + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Total record count number.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.PortalSettingsContract"]] = None, + count: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalSettingsContract(ProxyResource): + """Portal Settings for the Developer Portal. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Portal Settings contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.PortalSettingsContractProperties + """ + + properties: Optional["_models.PortalSettingsContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Portal Settings contract properties.""" + + __flattened_items = ["url", "validation_key", "subscriptions", "user_registration", "enabled", "terms_of_service"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PortalSettingsContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PortalSettingsContractProperties(_Model): + """Sign-in settings contract properties. + + :ivar url: A delegation Url. + :vartype url: str + :ivar validation_key: A base64-encoded validation key to validate, that a request is coming + from Azure API Management. + :vartype validation_key: str + :ivar subscriptions: Subscriptions delegation settings. + :vartype subscriptions: + ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties + :ivar user_registration: User registration delegation settings. + :vartype user_registration: + ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties + :ivar enabled: Redirect Anonymous users to the Sign-In page. + :vartype enabled: bool + :ivar terms_of_service: Terms of service contract properties. + :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + """ + + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A delegation Url.""" + validation_key: Optional[str] = rest_field( + name="validationKey", visibility=["read", "create", "update", "delete", "query"] + ) + """A base64-encoded validation key to validate, that a request is coming from Azure API + Management.""" + subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Subscriptions delegation settings.""" + user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = rest_field( + name="userRegistration", visibility=["read", "create", "update", "delete", "query"] + ) + """User registration delegation settings.""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Redirect Anonymous users to the Sign-In page.""" + terms_of_service: Optional["_models.TermsOfServiceProperties"] = rest_field( + name="termsOfService", visibility=["read", "create", "update", "delete", "query"] + ) + """Terms of service contract properties.""" + + @overload + def __init__( + self, + *, + url: Optional[str] = None, + validation_key: Optional[str] = None, + subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = None, + user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = None, + enabled: Optional[bool] = None, + terms_of_service: Optional["_models.TermsOfServiceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalSettingValidationKeyContract(_Model): + """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + + :ivar validation_key: This is secret value of the validation key in portal settings. + :vartype validation_key: str + """ + + validation_key: Optional[str] = rest_field( + name="validationKey", visibility=["read", "create", "update", "delete", "query"] + ) + """This is secret value of the validation key in portal settings.""" + + @overload + def __init__( + self, + *, + validation_key: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalSigninSettingProperties(_Model): + """Sign-in settings contract properties. + + :ivar enabled: Redirect Anonymous users to the Sign-In page. + :vartype enabled: bool + """ + + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Redirect Anonymous users to the Sign-In page.""" + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PortalSigninSettings(ProxyResource): + """Sign-In settings for the Developer Portal. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Sign-in settings contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.PortalSigninSettingProperties + """ + + properties: Optional["_models.PortalSigninSettingProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Sign-in settings contract properties.""" + + __flattened_items = ["enabled"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PortalSigninSettingProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PortalSignupSettings(ProxyResource): + """Sign-Up settings for a developer portal. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Sign-up settings contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.PortalSignupSettingsProperties + """ + + properties: Optional["_models.PortalSignupSettingsProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Sign-up settings contract properties.""" + + __flattened_items = ["enabled", "terms_of_service"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PortalSignupSettingsProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PortalSignupSettingsProperties(_Model): + """Sign-up settings contract properties. + + :ivar enabled: Allow users to sign up on a developer portal. + :vartype enabled: bool + :ivar terms_of_service: Terms of service contract properties. + :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + """ + + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Allow users to sign up on a developer portal.""" + terms_of_service: Optional["_models.TermsOfServiceProperties"] = rest_field( + name="termsOfService", visibility=["read", "create", "update", "delete", "query"] + ) + """Terms of service contract properties.""" + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + terms_of_service: Optional["_models.TermsOfServiceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpoint(_Model): + """The private endpoint resource. + + :ivar id: The resource identifier of the private endpoint. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """The resource identifier of the private endpoint.""" + + +class PrivateEndpointConnection(Resource): + """A private endpoint connection resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionProperties + """ + + properties: Optional["_models.PrivateEndpointConnectionProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["private_endpoint", "private_link_service_connection_state", "provisioning_state"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateEndpointConnectionProperties(_Model): + """Properties of the private endpoint connection. + + :ivar private_endpoint: The private endpoint resource. + :vartype private_endpoint: ~azure.mgmt.apimanagement.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionProvisioningState + """ + + private_endpoint: Optional["_models.PrivateEndpoint"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """The private endpoint resource.""" + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState" = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of information about the state of the connection between service consumer and + provider. Required.""" + provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = rest_field( + name="provisioningState", visibility=["read"] + ) + """The provisioning state of the private endpoint connection resource. Known values are: + \"Succeeded\", \"Creating\", \"Deleting\", and \"Failed\".""" + + @overload + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpointConnectionRequest(_Model): + """A request to approve or reject a private endpoint connection. + + :ivar id: Private Endpoint Connection Resource Id. + :vartype id: str + :ivar properties: The connection state of the private endpoint connection. + :vartype properties: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Private Endpoint Connection Resource Id.""" + properties: Optional["_models.PrivateEndpointConnectionRequestProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The connection state of the private endpoint connection.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + properties: Optional["_models.PrivateEndpointConnectionRequestProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpointConnectionRequestProperties(_Model): # pylint: disable=name-too-long + """The connection state of the private endpoint connection. + + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState + """ + + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of information about the state of the connection between service consumer and + provider.""" + + @overload + def __init__( + self, + *, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateEndpointConnectionWrapperProperties(_Model): # pylint: disable=name-too-long + """Properties of the PrivateEndpointConnectProperties. + + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.apimanagement.models.ArmIdWrapper + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. Required. + :vartype private_link_service_connection_state: + ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + :vartype provisioning_state: str + :ivar group_ids: All the Group ids. + :vartype group_ids: list[str] + """ + + private_endpoint: Optional["_models.ArmIdWrapper"] = rest_field( + name="privateEndpoint", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource of private end point.""" + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState" = rest_field( + name="privateLinkServiceConnectionState", visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of information about the state of the connection between service consumer and + provider. Required.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The provisioning state of the private endpoint connection resource.""" + group_ids: Optional[list[str]] = rest_field(name="groupIds", visibility=["read"]) + """All the Group ids.""" + + @overload + def __init__( + self, + *, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.ArmIdWrapper"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResource(Resource): + """A private link resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Resource properties. + :vartype properties: ~azure.mgmt.apimanagement.models.PrivateLinkResourceProperties + """ + + properties: Optional["_models.PrivateLinkResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["group_id", "required_members", "required_zone_names"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PrivateLinkResourceProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PrivateLinkResourceListResult(_Model): + """The response of a PrivateLinkResource list operation. + + :ivar value: The PrivateLinkResource items on this page. Required. + :vartype value: list[~azure.mgmt.apimanagement.models.PrivateLinkResource] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + value: list["_models.PrivateLinkResource"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The PrivateLinkResource items on this page. Required.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """The link to the next page of items.""" + + @overload + def __init__( + self, + *, + value: list["_models.PrivateLinkResource"], + next_link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkResourceProperties(_Model): + """Properties of a private link resource. + + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + group_id: Optional[str] = rest_field(name="groupId", visibility=["read"]) + """The private link resource group id.""" + required_members: Optional[list[str]] = rest_field(name="requiredMembers", visibility=["read"]) + """The private link resource required member names.""" + required_zone_names: Optional[list[str]] = rest_field( + name="requiredZoneNames", visibility=["read", "create", "update", "delete", "query"] + ) + """The private link resource private link DNS zone name.""" + + @overload + def __init__( + self, + *, + required_zone_names: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PrivateLinkServiceConnectionState(_Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or ~azure.mgmt.apimanagement.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the + service. Known values are: \"Pending\", \"Approved\", and \"Rejected\".""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The reason for approval/rejection of the connection.""" + actions_required: Optional[str] = rest_field( + name="actionsRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """A message indicating if changes on the service provider require any updates on the consumer.""" + + @overload + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProductApiLinkContract(ProxyResource): + """Product-API link details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Product-API link entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.ProductApiLinkContractProperties + """ + + properties: Optional["_models.ProductApiLinkContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Product-API link entity contract properties.""" + + __flattened_items = ["api_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ProductApiLinkContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ProductApiLinkContractProperties(_Model): + """Product-API link entity properties. + + :ivar api_id: Full resource Id of an API. Required. + :vartype api_id: str + """ + + api_id: str = rest_field(name="apiId", visibility=["read", "create", "update", "delete", "query"]) + """Full resource Id of an API. Required.""" + + @overload + def __init__( + self, + *, + api_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProductApplicationContract(_Model): + """Specifies Microsoft Entra settings needed to authorize product API calls using client + applications. + + :ivar entra: Specifies Microsoft Entra settings needed to authorize product API calls using + client application with Microsoft Entra OAuth token. + :vartype entra: ~azure.mgmt.apimanagement.models.ProductApplicationContractEntra + """ + + entra: Optional["_models.ProductApplicationContractEntra"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies Microsoft Entra settings needed to authorize product API calls using client + application with Microsoft Entra OAuth token.""" + + @overload + def __init__( + self, + *, + entra: Optional["_models.ProductApplicationContractEntra"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProductApplicationContractEntra(_Model): + """Specifies Microsoft Entra settings needed to authorize product API calls using client + application with Microsoft Entra OAuth token. + + :ivar application_id: Product facing EntraID application client ID. + :vartype application_id: str + :ivar audience: The EntraID application audience claim. The audience claim is used to validate + the token. + :vartype audience: str + """ + + application_id: Optional[str] = rest_field( + name="applicationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Product facing EntraID application client ID.""" + audience: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The EntraID application audience claim. The audience claim is used to validate the token.""" + + @overload + def __init__( + self, + *, + application_id: Optional[str] = None, + audience: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProductContract(ProxyResource): + """Product details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Product entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.ProductContractProperties + """ + + properties: Optional["_models.ProductContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Product entity contract properties.""" + + __flattened_items = [ + "description", + "terms", + "subscription_required", + "approval_required", + "subscriptions_limit", + "authentication_type", + "application", + "state", + "display_name", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ProductContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ProductEntityBaseParameters(_Model): + """Product Entity Base Parameters. + + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. + :vartype subscriptions_limit: int + :ivar authentication_type: Type of supported authentication for the product. The application + configuration is required for application-token authentication type. The subscription-key + authentication type is used by default. If the property is omitted, the subscription-key + authentication type is used. + :vartype authentication_type: list[str or ~azure.mgmt.apimanagement.models.ProductAuthType] + :ivar application: Specifies identity provider settings needed to authorize applications API + calls. + :vartype application: ~azure.mgmt.apimanagement.models.ProductEntityBaseParametersApplication + :ivar state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Known values are: "notPublished" and "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Product description. May include HTML formatting tags.""" + terms: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Product terms of use. Developers trying to subscribe to the product will be presented and + required to accept these terms before they can complete the subscription process.""" + subscription_required: Optional[bool] = rest_field( + name="subscriptionRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether a product subscription is required for accessing APIs included in this product. If + true, the product is referred to as \"protected\" and a valid subscription key is required for + a request to an API included in the product to succeed. If false, the product is referred to as + \"open\" and requests to an API included in the product can be made without a subscription key. + If property is omitted when creating a new product it's value is assumed to be true.""" + approval_required: Optional[bool] = rest_field( + name="approvalRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """whether subscription approval is required. If false, new subscriptions will be approved + automatically enabling developers to call the product’s APIs immediately after subscribing. If + true, administrators must manually approve the subscription before the developer can any of the + product’s APIs. Can be present only if subscriptionRequired property is present and has a value + of false.""" + subscriptions_limit: Optional[int] = rest_field( + name="subscriptionsLimit", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether the number of subscriptions a user can have to this product at the same time. Set to + null or omit to allow unlimited per user subscriptions. Can be present only if + subscriptionRequired property is present and has a value of false.""" + authentication_type: Optional[list[Union[str, "_models.ProductAuthType"]]] = rest_field( + name="authenticationType", visibility=["read", "create", "update", "delete", "query"] + ) + """Type of supported authentication for the product. The application configuration is required for + application-token authentication type. The subscription-key authentication type is used by + default. If the property is omitted, the subscription-key authentication type is used.""" + application: Optional["_models.ProductEntityBaseParametersApplication"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Specifies identity provider settings needed to authorize applications API calls.""" + state: Optional[Union[str, "_models.ProductState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """whether product is published or not. Published products are discoverable by users of developer + portal. Non published products are visible only to administrators. Default state of Product is + notPublished. Known values are: \"notPublished\" and \"published\".""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + authentication_type: Optional[list[Union[str, "_models.ProductAuthType"]]] = None, + application: Optional["_models.ProductEntityBaseParametersApplication"] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProductContractProperties(ProductEntityBaseParameters): + """Product profile. + + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. + :vartype subscriptions_limit: int + :ivar authentication_type: Type of supported authentication for the product. The application + configuration is required for application-token authentication type. The subscription-key + authentication type is used by default. If the property is omitted, the subscription-key + authentication type is used. + :vartype authentication_type: list[str or ~azure.mgmt.apimanagement.models.ProductAuthType] + :ivar application: Specifies identity provider settings needed to authorize applications API + calls. + :vartype application: ~azure.mgmt.apimanagement.models.ProductEntityBaseParametersApplication + :ivar state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Known values are: "notPublished" and "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState + :ivar display_name: Product name. Required. + :vartype display_name: str + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Product name. Required.""" + + @overload + def __init__( + self, + *, + display_name: str, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + authentication_type: Optional[list[Union[str, "_models.ProductAuthType"]]] = None, + application: Optional["_models.ProductEntityBaseParametersApplication"] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProductEntityBaseParametersApplication(ProductApplicationContract): + """Specifies identity provider settings needed to authorize applications API calls. + + :ivar entra: Specifies Microsoft Entra settings needed to authorize product API calls using + client application with Microsoft Entra OAuth token. + :vartype entra: ~azure.mgmt.apimanagement.models.ProductApplicationContractEntra + """ + + @overload + def __init__( + self, + *, + entra: Optional["_models.ProductApplicationContractEntra"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProductGroupLinkContract(ProxyResource): + """Product-group link details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Product-group link entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.ProductGroupLinkContractProperties + """ + + properties: Optional["_models.ProductGroupLinkContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Product-group link entity contract properties.""" + + __flattened_items = ["group_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ProductGroupLinkContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ProductGroupLinkContractProperties(_Model): + """Product-group link entity properties. + + :ivar group_id: Full resource Id of a group. Required. + :vartype group_id: str + """ + + group_id: str = rest_field(name="groupId", visibility=["read", "create", "update", "delete", "query"]) + """Full resource Id of a group. Required.""" + + @overload + def __init__( + self, + *, + group_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProductTagResourceContractProperties(ProductEntityBaseParameters): + """Product profile. + + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. + :vartype subscriptions_limit: int + :ivar authentication_type: Type of supported authentication for the product. The application + configuration is required for application-token authentication type. The subscription-key + authentication type is used by default. If the property is omitted, the subscription-key + authentication type is used. + :vartype authentication_type: list[str or ~azure.mgmt.apimanagement.models.ProductAuthType] + :ivar application: Specifies identity provider settings needed to authorize applications API + calls. + :vartype application: ~azure.mgmt.apimanagement.models.ProductEntityBaseParametersApplication + :ivar state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Known values are: "notPublished" and "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState + :ivar id: Identifier of the product in the form of /products/{productId}. + :vartype id: str + :ivar name: Product name. Required. + :vartype name: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the product in the form of /products/{productId}.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Product name. Required.""" + + @overload + def __init__( + self, + *, + name: str, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + authentication_type: Optional[list[Union[str, "_models.ProductAuthType"]]] = None, + application: Optional["_models.ProductEntityBaseParametersApplication"] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ProductUpdateParameters(_Model): + """Product Update parameters. + + :ivar properties: Product entity Update contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.ProductUpdateProperties + """ + + properties: Optional["_models.ProductUpdateProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Product entity Update contract properties.""" + + __flattened_items = [ + "description", + "terms", + "subscription_required", + "approval_required", + "subscriptions_limit", + "authentication_type", + "application", + "state", + "display_name", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ProductUpdateProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ProductUpdateProperties(ProductEntityBaseParameters): + """Parameters supplied to the Update Product operation. + + :ivar description: Product description. May include HTML formatting tags. + :vartype description: str + :ivar terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :vartype terms: str + :ivar subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :vartype subscription_required: bool + :ivar approval_required: whether subscription approval is required. If false, new subscriptions + will be approved automatically enabling developers to call the product’s APIs immediately after + subscribing. If true, administrators must manually approve the subscription before the + developer can any of the product’s APIs. Can be present only if subscriptionRequired property + is present and has a value of false. + :vartype approval_required: bool + :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. + :vartype subscriptions_limit: int + :ivar authentication_type: Type of supported authentication for the product. The application + configuration is required for application-token authentication type. The subscription-key + authentication type is used by default. If the property is omitted, the subscription-key + authentication type is used. + :vartype authentication_type: list[str or ~azure.mgmt.apimanagement.models.ProductAuthType] + :ivar application: Specifies identity provider settings needed to authorize applications API + calls. + :vartype application: ~azure.mgmt.apimanagement.models.ProductEntityBaseParametersApplication + :ivar state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Known values are: "notPublished" and "published". + :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState + :ivar display_name: Product name. + :vartype display_name: str + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Product name.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + authentication_type: Optional[list[Union[str, "_models.ProductAuthType"]]] = None, + application: Optional["_models.ProductEntityBaseParametersApplication"] = None, + state: Optional[Union[str, "_models.ProductState"]] = None, + display_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaCounterCollection(_Model): + """Paged Quota Counter list representation. + + :ivar value: Quota counter values. + :vartype value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] + :ivar count: Total record count number across all pages. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + value: Optional[list["_models.QuotaCounterContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Quota counter values.""" + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Total record count number across all pages.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """Next page link if any.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.QuotaCounterContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaCounterContract(_Model): + """Quota counter details. + + :ivar counter_key: The Key value of the Counter. Must not be empty. Required. + :vartype counter_key: str + :ivar period_key: Identifier of the Period for which the counter was collected. Must not be + empty. Required. + :vartype period_key: str + :ivar period_start_time: The date of the start of Counter Period. The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. + :vartype period_start_time: ~datetime.datetime + :ivar period_end_time: The date of the end of Counter Period. The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. + :vartype period_end_time: ~datetime.datetime + :ivar value: Quota Value Properties. + :vartype value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties + """ + + counter_key: str = rest_field(name="counterKey", visibility=["read", "create", "update", "delete", "query"]) + """The Key value of the Counter. Must not be empty. Required.""" + period_key: str = rest_field(name="periodKey", visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the Period for which the counter was collected. Must not be empty. Required.""" + period_start_time: datetime.datetime = rest_field( + name="periodStartTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The date of the start of Counter Period. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required.""" + period_end_time: datetime.datetime = rest_field( + name="periodEndTime", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The date of the end of Counter Period. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required.""" + value: Optional["_models.QuotaCounterValueContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Quota Value Properties.""" + + @overload + def __init__( + self, + *, + counter_key: str, + period_key: str, + period_start_time: datetime.datetime, + period_end_time: datetime.datetime, + value: Optional["_models.QuotaCounterValueContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaCounterValueContractProperties(_Model): + """Quota counter value details. + + :ivar calls_count: Number of times Counter was called. + :vartype calls_count: int + :ivar kb_transferred: Data Transferred in KiloBytes. + :vartype kb_transferred: float + """ + + calls_count: Optional[int] = rest_field( + name="callsCount", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of times Counter was called.""" + kb_transferred: Optional[float] = rest_field( + name="kbTransferred", visibility=["read", "create", "update", "delete", "query"] + ) + """Data Transferred in KiloBytes.""" + + @overload + def __init__( + self, + *, + calls_count: Optional[int] = None, + kb_transferred: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QuotaCounterValueUpdateContract(_Model): + """Quota counter value details. + + :ivar properties: Quota counter value details. + :vartype properties: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties + """ + + properties: Optional["_models.QuotaCounterValueContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Quota counter value details.""" + + __flattened_items = ["calls_count", "kb_transferred"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.QuotaCounterValueContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RecipientEmailCollection(_Model): + """Paged Recipient User list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] + :ivar count: Total record count number across all pages. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + value: Optional[list["_models.RecipientEmailContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Page values.""" + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Total record count number across all pages.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """Next page link if any.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.RecipientEmailContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecipientEmailContract(ProxyResource): + """Recipient Email details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Recipient Email contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.RecipientEmailContractProperties + """ + + properties: Optional["_models.RecipientEmailContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Recipient Email contract properties.""" + + __flattened_items = ["email"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RecipientEmailContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RecipientEmailContractProperties(_Model): + """Recipient Email Contract Properties. + + :ivar email: User Email subscribed to notification. + :vartype email: str + """ + + email: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """User Email subscribed to notification.""" + + @overload + def __init__( + self, + *, + email: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecipientsContractProperties(_Model): + """Notification Parameter contract. + + :ivar emails: List of Emails subscribed for the notification. + :vartype emails: list[str] + :ivar users: List of Users subscribed for the notification. + :vartype users: list[str] + """ + + emails: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of Emails subscribed for the notification.""" + users: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of Users subscribed for the notification.""" + + @overload + def __init__( + self, + *, + emails: Optional[list[str]] = None, + users: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecipientUserCollection(_Model): + """Paged Recipient User list representation. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] + :ivar count: Total record count number across all pages. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + value: Optional[list["_models.RecipientUserContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Page values.""" + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Total record count number across all pages.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """Next page link if any.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.RecipientUserContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RecipientUserContract(ProxyResource): + """Recipient User details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Recipient User entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.RecipientUsersContractProperties + """ + + properties: Optional["_models.RecipientUsersContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Recipient User entity contract properties.""" + + __flattened_items = ["user_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RecipientUsersContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RecipientUsersContractProperties(_Model): + """Recipient User Contract Properties. + + :ivar user_id: API Management UserId subscribed to notification. + :vartype user_id: str + """ + + user_id: Optional[str] = rest_field(name="userId", visibility=["read", "create", "update", "delete", "query"]) + """API Management UserId subscribed to notification.""" + + @overload + def __init__( + self, + *, + user_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RegionContract(_Model): + """Region profile. + + :ivar name: Region name. + :vartype name: str + :ivar is_master_region: whether Region is the master region. + :vartype is_master_region: bool + :ivar is_deleted: whether Region is deleted. + :vartype is_deleted: bool + """ + + name: Optional[str] = rest_field(visibility=["read"]) + """Region name.""" + is_master_region: Optional[bool] = rest_field( + name="isMasterRegion", visibility=["read", "create", "update", "delete", "query"] + ) + """whether Region is the master region.""" + is_deleted: Optional[bool] = rest_field( + name="isDeleted", visibility=["read", "create", "update", "delete", "query"] + ) + """whether Region is deleted.""" + + @overload + def __init__( + self, + *, + is_master_region: Optional[bool] = None, + is_deleted: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RegistrationDelegationSettingsProperties(_Model): + """User registration delegation settings properties. + + :ivar enabled: Enable or disable delegation for user registration. + :vartype enabled: bool + """ + + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Enable or disable delegation for user registration.""" + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RemotePrivateEndpointConnectionWrapper(_Model): + """Remote Private Endpoint Connection resource. + + :ivar id: Private Endpoint connection resource id. + :vartype id: str + :ivar name: Private Endpoint Connection Name. + :vartype name: str + :ivar type: Private Endpoint Connection Resource Type. + :vartype type: str + :ivar properties: Resource properties. + :vartype properties: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionWrapperProperties + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Private Endpoint connection resource id.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Private Endpoint Connection Name.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Private Endpoint Connection Resource Type.""" + properties: Optional["_models.PrivateEndpointConnectionWrapperProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Resource properties.""" + + __flattened_items = ["private_endpoint", "private_link_service_connection_state", "provisioning_state", "group_ids"] + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + type: Optional[str] = None, + properties: Optional["_models.PrivateEndpointConnectionWrapperProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ReportRecordContract(_Model): + """Report data. + + :ivar name: Name depending on report endpoint specifies product, API, operation or developer + name. + :vartype name: str + :ivar timestamp: Start of aggregation period. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype timestamp: ~datetime.datetime + :ivar interval: Length of aggregation period. Interval must be multiple of 15 minutes and may + not be zero. The value should be in ISO 8601 format + (`http://en.wikipedia.org/wiki/ISO_8601#Durations + `_). + :vartype interval: str + :ivar country: Country to which this record data is related. + :vartype country: str + :ivar region: Country region to which this record data is related. + :vartype region: str + :ivar zip: Zip code to which this record data is related. + :vartype zip: str + :ivar user_id: User identifier path. /users/{userId}. + :vartype user_id: str + :ivar product_id: Product identifier path. /products/{productId}. + :vartype product_id: str + :ivar api_id: API identifier path. /apis/{apiId}. + :vartype api_id: str + :ivar operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. + :vartype operation_id: str + :ivar api_region: API region identifier. + :vartype api_region: str + :ivar subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. + :vartype subscription_id: str + :ivar call_count_success: Number of successful calls. This includes calls returning + HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect. + :vartype call_count_success: int + :ivar call_count_blocked: Number of calls blocked due to invalid credentials. This includes + calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and + HttpStatusCode.TooManyRequests. + :vartype call_count_blocked: int + :ivar call_count_failed: Number of calls failed due to gateway or backend errors. This includes + calls returning HttpStatusCode.BadRequest(400) and any Code between + HttpStatusCode.InternalServerError (500) and 600. + :vartype call_count_failed: int + :ivar call_count_other: Number of other calls. + :vartype call_count_other: int + :ivar call_count_total: Total number of calls. + :vartype call_count_total: int + :ivar bandwidth: Bandwidth consumed. + :vartype bandwidth: int + :ivar cache_hit_count: Number of times when content was served from cache policy. + :vartype cache_hit_count: int + :ivar cache_miss_count: Number of times content was fetched from backend. + :vartype cache_miss_count: int + :ivar api_time_avg: Average time it took to process request. + :vartype api_time_avg: float + :ivar api_time_min: Minimum time it took to process request. + :vartype api_time_min: float + :ivar api_time_max: Maximum time it took to process request. + :vartype api_time_max: float + :ivar service_time_avg: Average time it took to process request on backend. + :vartype service_time_avg: float + :ivar service_time_min: Minimum time it took to process request on backend. + :vartype service_time_min: float + :ivar service_time_max: Maximum time it took to process request on backend. + :vartype service_time_max: float + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Name depending on report endpoint specifies product, API, operation or developer name.""" + timestamp: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Start of aggregation period. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + interval: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Length of aggregation period. Interval must be multiple of 15 minutes and may not be zero. The + value should be in ISO 8601 format (`http://en.wikipedia.org/wiki/ISO_8601#Durations + `_).""" + country: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Country to which this record data is related.""" + region: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Country region to which this record data is related.""" + zip: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Zip code to which this record data is related.""" + user_id: Optional[str] = rest_field(name="userId", visibility=["read"]) + """User identifier path. /users/{userId}.""" + product_id: Optional[str] = rest_field(name="productId", visibility=["read"]) + """Product identifier path. /products/{productId}.""" + api_id: Optional[str] = rest_field(name="apiId", visibility=["read", "create", "update", "delete", "query"]) + """API identifier path. /apis/{apiId}.""" + operation_id: Optional[str] = rest_field( + name="operationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Operation identifier path. /apis/{apiId}/operations/{operationId}.""" + api_region: Optional[str] = rest_field(name="apiRegion", visibility=["read", "create", "update", "delete", "query"]) + """API region identifier.""" + subscription_id: Optional[str] = rest_field( + name="subscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription identifier path. /subscriptions/{subscriptionId}.""" + call_count_success: Optional[int] = rest_field( + name="callCountSuccess", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of successful calls. This includes calls returning HttpStatusCode <= 301 and + HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect.""" + call_count_blocked: Optional[int] = rest_field( + name="callCountBlocked", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of calls blocked due to invalid credentials. This includes calls returning + HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and HttpStatusCode.TooManyRequests.""" + call_count_failed: Optional[int] = rest_field( + name="callCountFailed", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of calls failed due to gateway or backend errors. This includes calls returning + HttpStatusCode.BadRequest(400) and any Code between HttpStatusCode.InternalServerError (500) + and 600.""" + call_count_other: Optional[int] = rest_field( + name="callCountOther", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of other calls.""" + call_count_total: Optional[int] = rest_field( + name="callCountTotal", visibility=["read", "create", "update", "delete", "query"] + ) + """Total number of calls.""" + bandwidth: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Bandwidth consumed.""" + cache_hit_count: Optional[int] = rest_field( + name="cacheHitCount", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of times when content was served from cache policy.""" + cache_miss_count: Optional[int] = rest_field( + name="cacheMissCount", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of times content was fetched from backend.""" + api_time_avg: Optional[float] = rest_field( + name="apiTimeAvg", visibility=["read", "create", "update", "delete", "query"] + ) + """Average time it took to process request.""" + api_time_min: Optional[float] = rest_field( + name="apiTimeMin", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimum time it took to process request.""" + api_time_max: Optional[float] = rest_field( + name="apiTimeMax", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum time it took to process request.""" + service_time_avg: Optional[float] = rest_field( + name="serviceTimeAvg", visibility=["read", "create", "update", "delete", "query"] + ) + """Average time it took to process request on backend.""" + service_time_min: Optional[float] = rest_field( + name="serviceTimeMin", visibility=["read", "create", "update", "delete", "query"] + ) + """Minimum time it took to process request on backend.""" + service_time_max: Optional[float] = rest_field( + name="serviceTimeMax", visibility=["read", "create", "update", "delete", "query"] + ) + """Maximum time it took to process request on backend.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + name: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + interval: Optional[str] = None, + country: Optional[str] = None, + region: Optional[str] = None, + zip: Optional[str] = None, + api_id: Optional[str] = None, + operation_id: Optional[str] = None, + api_region: Optional[str] = None, + subscription_id: Optional[str] = None, + call_count_success: Optional[int] = None, + call_count_blocked: Optional[int] = None, + call_count_failed: Optional[int] = None, + call_count_other: Optional[int] = None, + call_count_total: Optional[int] = None, + bandwidth: Optional[int] = None, + cache_hit_count: Optional[int] = None, + cache_miss_count: Optional[int] = None, + api_time_avg: Optional[float] = None, + api_time_min: Optional[float] = None, + api_time_max: Optional[float] = None, + service_time_avg: Optional[float] = None, + service_time_min: Optional[float] = None, + service_time_max: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RepresentationContract(_Model): + """Operation request/response representation details. + + :ivar content_type: Specifies a registered or custom content type for this representation, e.g. + application/xml. Required. + :vartype content_type: str + :ivar schema_id: Schema identifier. Applicable only if 'contentType' value is neither + 'application/x-www-form-urlencoded' nor 'multipart/form-data'. + :vartype schema_id: str + :ivar type_name: Type name defined by the schema. Applicable only if 'contentType' value is + neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. + :vartype type_name: str + :ivar form_parameters: Collection of form parameters. Required if 'contentType' value is either + 'application/x-www-form-urlencoded' or 'multipart/form-data'.. + :vartype form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar examples: Exampled defined for the representation. + :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] + """ + + content_type: str = rest_field(name="contentType", visibility=["read", "create", "update", "delete", "query"]) + """Specifies a registered or custom content type for this representation, e.g. application/xml. + Required.""" + schema_id: Optional[str] = rest_field(name="schemaId", visibility=["read", "create", "update", "delete", "query"]) + """Schema identifier. Applicable only if 'contentType' value is neither + 'application/x-www-form-urlencoded' nor 'multipart/form-data'.""" + type_name: Optional[str] = rest_field(name="typeName", visibility=["read", "create", "update", "delete", "query"]) + """Type name defined by the schema. Applicable only if 'contentType' value is neither + 'application/x-www-form-urlencoded' nor 'multipart/form-data'.""" + form_parameters: Optional[list["_models.ParameterContract"]] = rest_field( + name="formParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of form parameters. Required if 'contentType' value is either + 'application/x-www-form-urlencoded' or 'multipart/form-data'..""" + examples: Optional[dict[str, "_models.ParameterExampleContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Exampled defined for the representation.""" + + @overload + def __init__( + self, + *, + content_type: str, + schema_id: Optional[str] = None, + type_name: Optional[str] = None, + form_parameters: Optional[list["_models.ParameterContract"]] = None, + examples: Optional[dict[str, "_models.ParameterExampleContract"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RequestContract(_Model): + """Operation request details. + + :ivar description: Operation request description. + :vartype description: str + :ivar query_parameters: Collection of operation request query parameters. + :vartype query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar headers: Collection of operation request headers. + :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] + :ivar representations: Collection of operation request representations. + :vartype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation request description.""" + query_parameters: Optional[list["_models.ParameterContract"]] = rest_field( + name="queryParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of operation request query parameters.""" + headers: Optional[list["_models.ParameterContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of operation request headers.""" + representations: Optional[list["_models.RepresentationContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of operation request representations.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + query_parameters: Optional[list["_models.ParameterContract"]] = None, + headers: Optional[list["_models.ParameterContract"]] = None, + representations: Optional[list["_models.RepresentationContract"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RequestReportRecordContract(_Model): + """Request Report data. + + :ivar api_id: API identifier path. /apis/{apiId}. + :vartype api_id: str + :ivar operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. + :vartype operation_id: str + :ivar product_id: Product identifier path. /products/{productId}. + :vartype product_id: str + :ivar user_id: User identifier path. /users/{userId}. + :vartype user_id: str + :ivar method: The HTTP method associated with this request.. + :vartype method: str + :ivar url: The full URL associated with this request. + :vartype url: str + :ivar ip_address: The client IP address associated with this request. + :vartype ip_address: str + :ivar backend_response_code: The HTTP status code received by the gateway as a result of + forwarding this request to the backend. + :vartype backend_response_code: str + :ivar response_code: The HTTP status code returned by the gateway. + :vartype response_code: int + :ivar response_size: The size of the response returned by the gateway. + :vartype response_size: int + :ivar timestamp: The date and time when this request was received by the gateway in ISO 8601 + format. + :vartype timestamp: ~datetime.datetime + :ivar cache: Specifies if response cache was involved in generating the response. If the value + is none, the cache was not used. If the value is hit, cached response was returned. If the + value is miss, the cache was used but lookup resulted in a miss and request was fulfilled by + the backend. + :vartype cache: str + :ivar api_time: The total time it took to process this request. + :vartype api_time: float + :ivar service_time: he time it took to forward this request to the backend and get the response + back. + :vartype service_time: float + :ivar api_region: Azure region where the gateway that processed this request is located. + :vartype api_region: str + :ivar subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. + :vartype subscription_id: str + :ivar request_id: Request Identifier. + :vartype request_id: str + :ivar request_size: The size of this request.. + :vartype request_size: int + """ + + api_id: Optional[str] = rest_field(name="apiId", visibility=["read", "create", "update", "delete", "query"]) + """API identifier path. /apis/{apiId}.""" + operation_id: Optional[str] = rest_field( + name="operationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Operation identifier path. /apis/{apiId}/operations/{operationId}.""" + product_id: Optional[str] = rest_field(name="productId", visibility=["read"]) + """Product identifier path. /products/{productId}.""" + user_id: Optional[str] = rest_field(name="userId", visibility=["read"]) + """User identifier path. /users/{userId}.""" + method: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The HTTP method associated with this request..""" + url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The full URL associated with this request.""" + ip_address: Optional[str] = rest_field(name="ipAddress", visibility=["read", "create", "update", "delete", "query"]) + """The client IP address associated with this request.""" + backend_response_code: Optional[str] = rest_field( + name="backendResponseCode", visibility=["read", "create", "update", "delete", "query"] + ) + """The HTTP status code received by the gateway as a result of forwarding this request to the + backend.""" + response_code: Optional[int] = rest_field( + name="responseCode", visibility=["read", "create", "update", "delete", "query"] + ) + """The HTTP status code returned by the gateway.""" + response_size: Optional[int] = rest_field( + name="responseSize", visibility=["read", "create", "update", "delete", "query"] + ) + """The size of the response returned by the gateway.""" + timestamp: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The date and time when this request was received by the gateway in ISO 8601 format.""" + cache: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Specifies if response cache was involved in generating the response. If the value is none, the + cache was not used. If the value is hit, cached response was returned. If the value is miss, + the cache was used but lookup resulted in a miss and request was fulfilled by the backend.""" + api_time: Optional[float] = rest_field(name="apiTime", visibility=["read", "create", "update", "delete", "query"]) + """The total time it took to process this request.""" + service_time: Optional[float] = rest_field( + name="serviceTime", visibility=["read", "create", "update", "delete", "query"] + ) + """he time it took to forward this request to the backend and get the response back.""" + api_region: Optional[str] = rest_field(name="apiRegion", visibility=["read", "create", "update", "delete", "query"]) + """Azure region where the gateway that processed this request is located.""" + subscription_id: Optional[str] = rest_field( + name="subscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription identifier path. /subscriptions/{subscriptionId}.""" + request_id: Optional[str] = rest_field(name="requestId", visibility=["read", "create", "update", "delete", "query"]) + """Request Identifier.""" + request_size: Optional[int] = rest_field( + name="requestSize", visibility=["read", "create", "update", "delete", "query"] + ) + """The size of this request..""" + + @overload + def __init__( + self, + *, + api_id: Optional[str] = None, + operation_id: Optional[str] = None, + method: Optional[str] = None, + url: Optional[str] = None, + ip_address: Optional[str] = None, + backend_response_code: Optional[str] = None, + response_code: Optional[int] = None, + response_size: Optional[int] = None, + timestamp: Optional[datetime.datetime] = None, + cache: Optional[str] = None, + api_time: Optional[float] = None, + service_time: Optional[float] = None, + api_region: Optional[str] = None, + subscription_id: Optional[str] = None, + request_id: Optional[str] = None, + request_size: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResolverContract(ProxyResource): + """GraphQL API Resolver details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Resolver Contract. + :vartype properties: ~azure.mgmt.apimanagement.models.ResolverEntityBaseContract + """ + + properties: Optional["_models.ResolverEntityBaseContract"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Resolver Contract.""" + + __flattened_items = ["display_name", "path", "description"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ResolverEntityBaseContract"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ResolverEntityBaseContract(_Model): + """GraphQL API Resolver Entity Base Contract details. + + :ivar display_name: Resolver Name. + :vartype display_name: str + :ivar path: Path is type/field being resolved. + :vartype path: str + :ivar description: Description of the resolver. May include HTML formatting tags. + :vartype description: str + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Resolver Name.""" + path: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Path is type/field being resolved.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the resolver. May include HTML formatting tags.""" + + @overload + def __init__( + self, + *, + display_name: Optional[str] = None, + path: Optional[str] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResolverUpdateContract(_Model): + """GraphQL API Resolver Update Contract details. + + :ivar properties: Properties of the GraphQL API Resolver entity that can be updated. + :vartype properties: ~azure.mgmt.apimanagement.models.ResolverUpdateContractProperties + """ + + properties: Optional["_models.ResolverUpdateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the GraphQL API Resolver entity that can be updated.""" + + __flattened_items = ["display_name", "path", "description"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ResolverUpdateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ResolverUpdateContractProperties(_Model): + """Resolver Update Contract Properties. + + :ivar display_name: Resolver Name. + :vartype display_name: str + :ivar path: Path is type/field being resolved. + :vartype path: str + :ivar description: Description of the resolver. May include HTML formatting tags. + :vartype description: str + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Resolver Name.""" + path: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Path is type/field being resolved.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the resolver. May include HTML formatting tags.""" + + @overload + def __init__( + self, + *, + display_name: Optional[str] = None, + path: Optional[str] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceCollection(_Model): + """A collection of resources. + + :ivar value: A collection of resources. + :vartype value: list[~azure.mgmt.apimanagement.models.ResourceCollectionValueItem] + :ivar count: Total record count number. + :vartype count: int + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + value: Optional[list["_models.ResourceCollectionValueItem"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """A collection of resources.""" + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Total record count number.""" + next_link: Optional[str] = rest_field(name="nextLink", visibility=["read", "create", "update", "delete", "query"]) + """Next page link if any.""" + + @overload + def __init__( + self, + *, + value: Optional[list["_models.ResourceCollectionValueItem"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceCollectionValueItem(ProxyResource): + """ResourceCollectionValueItem. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + """ + + +class ResourceLocationDataContract(_Model): + """Resource location data properties. + + :ivar name: A canonical name for the geographic or physical location. Required. + :vartype name: str + :ivar city: The city or locality where the resource is located. + :vartype city: str + :ivar district: The district, state, or province where the resource is located. + :vartype district: str + :ivar country_or_region: The country or region where the resource is located. + :vartype country_or_region: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A canonical name for the geographic or physical location. Required.""" + city: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The city or locality where the resource is located.""" + district: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The district, state, or province where the resource is located.""" + country_or_region: Optional[str] = rest_field( + name="countryOrRegion", visibility=["read", "create", "update", "delete", "query"] + ) + """The country or region where the resource is located.""" + + @overload + def __init__( + self, + *, + name: str, + city: Optional[str] = None, + district: Optional[str] = None, + country_or_region: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceSku(_Model): + """Describes an available API Management SKU. + + :ivar name: Name of the Sku. Known values are: "Developer", "Standard", "Premium", "Basic", + "Consumption", "Isolated", "BasicV2", "StandardV2", and "PremiumV2". + :vartype name: str or ~azure.mgmt.apimanagement.models.SkuType + """ + + name: Optional[Union[str, "_models.SkuType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Name of the Sku. Known values are: \"Developer\", \"Standard\", \"Premium\", \"Basic\", + \"Consumption\", \"Isolated\", \"BasicV2\", \"StandardV2\", and \"PremiumV2\".""" + + @overload + def __init__( + self, + *, + name: Optional[Union[str, "_models.SkuType"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ResourceSkuCapacity(_Model): + """Describes scaling information of a SKU. + + :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.ResourceSkuCapacityScaleType + """ + + minimum: Optional[int] = rest_field(visibility=["read"]) + """The minimum capacity.""" + maximum: Optional[int] = rest_field(visibility=["read"]) + """The maximum capacity that can be set.""" + default: Optional[int] = rest_field(visibility=["read"]) + """The default capacity.""" + scale_type: Optional[Union[str, "_models.ResourceSkuCapacityScaleType"]] = rest_field( + name="scaleType", visibility=["read"] + ) + """The scale type applicable to the sku. Known values are: \"automatic\", \"manual\", and + \"none\".""" + + +class ResourceSkuResult(_Model): + """Describes an available API Management service SKU. + + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :ivar sku: Specifies API Management SKU. + :vartype sku: ~azure.mgmt.apimanagement.models.ResourceSku + :ivar capacity: Specifies the number of API Management units. + :vartype capacity: ~azure.mgmt.apimanagement.models.ResourceSkuCapacity + """ + + resource_type: Optional[str] = rest_field(name="resourceType", visibility=["read"]) + """The type of resource the SKU applies to.""" + sku: Optional["_models.ResourceSku"] = rest_field(visibility=["read"]) + """Specifies API Management SKU.""" + capacity: Optional["_models.ResourceSkuCapacity"] = rest_field(visibility=["read"]) + """Specifies the number of API Management units.""" + + +class ResponseContract(_Model): + """Operation response details. + + :ivar status_code: Operation response HTTP status code. Required. + :vartype status_code: int + :ivar description: Operation response description. + :vartype description: str + :ivar representations: Collection of operation response representations. + :vartype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] + :ivar headers: Collection of operation response headers. + :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] + """ + + status_code: int = rest_field(name="statusCode", visibility=["read", "create", "update", "delete", "query"]) + """Operation response HTTP status code. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation response description.""" + representations: Optional[list["_models.RepresentationContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of operation response representations.""" + headers: Optional[list["_models.ParameterContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of operation response headers.""" + + @overload + def __init__( + self, + *, + status_code: int, + description: Optional[str] = None, + representations: Optional[list["_models.RepresentationContract"]] = None, + headers: Optional[list["_models.ParameterContract"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SamplingSettings(_Model): + """Sampling settings for Diagnostic. + + :ivar sampling_type: Sampling type. "fixed" + :vartype sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType + :ivar percentage: Rate of sampling for fixed-rate sampling. + :vartype percentage: float + """ + + sampling_type: Optional[Union[str, "_models.SamplingType"]] = rest_field( + name="samplingType", visibility=["read", "create", "update", "delete", "query"] + ) + """Sampling type. \"fixed\"""" + percentage: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Rate of sampling for fixed-rate sampling.""" + + @overload + def __init__( + self, + *, + sampling_type: Optional[Union[str, "_models.SamplingType"]] = None, + percentage: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SaveConfigurationParameter(_Model): + """Save Tenant Configuration Contract details. + + :ivar properties: Properties of the Save Configuration Parameters. + :vartype properties: ~azure.mgmt.apimanagement.models.SaveConfigurationParameterProperties + """ + + properties: Optional["_models.SaveConfigurationParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Save Configuration Parameters.""" + + __flattened_items = ["branch", "force"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SaveConfigurationParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SaveConfigurationParameterProperties(_Model): + """Parameters supplied to the Save Tenant Configuration operation. + + :ivar branch: The name of the Git branch in which to commit the current configuration snapshot. + Required. + :vartype branch: str + :ivar force: The value if true, the current configuration database is committed to the Git + repository, even if the Git repository has newer changes that would be overwritten. + :vartype force: bool + """ + + branch: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the Git branch in which to commit the current configuration snapshot. Required.""" + force: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The value if true, the current configuration database is committed to the Git repository, even + if the Git repository has newer changes that would be overwritten.""" + + @overload + def __init__( + self, + *, + branch: str, + force: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SchemaContract(ProxyResource): + """API Schema Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the API Schema. + :vartype properties: ~azure.mgmt.apimanagement.models.SchemaContractProperties + """ + + properties: Optional["_models.SchemaContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the API Schema.""" + + @overload + def __init__( + self, + *, + properties: Optional["_models.SchemaContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SchemaContractProperties(_Model): + """API Schema create or update contract Properties. + + :ivar content_type: Must be a valid a media type used in a Content-Type header as defined in + the RFC 2616. Media type of the schema document (e.g. application/json, application/xml).
+ - ``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``
- ``OData Schema`` use + ``application/vnd.ms-azure-apim.odata.schema``
- ``gRPC Schema`` use ``text/protobuf``. + Required. + :vartype content_type: str + :ivar document: Create or update Properties of the API Schema Document. Required. + :vartype document: ~azure.mgmt.apimanagement.models.SchemaDocumentProperties + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + content_type: str = rest_field(name="contentType", visibility=["read", "create", "update", "delete", "query"]) + """Must be a valid a media type used in a Content-Type header as defined in the RFC 2616. Media + type of the schema document (e.g. application/json, application/xml).
- ``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``
- ``OData Schema`` use + ``application/vnd.ms-azure-apim.odata.schema``
- ``gRPC Schema`` use ``text/protobuf``. + Required.""" + document: "_models.SchemaDocumentProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Create or update Properties of the API Schema Document. Required.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The provisioning state.""" + + __flattened_items = ["value", "definitions", "components"] + + @overload + def __init__( + self, + *, + content_type: str, + document: "_models.SchemaDocumentProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.document is None: + return None + return getattr(self.document, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.document is None: + self.document = self._attr_to_rest_field["document"]._class_type() + setattr(self.document, key, value) + else: + super().__setattr__(key, value) + + +class SchemaDocumentProperties(_Model): + """Api Schema Document Properties. + + :ivar value: Json escaped string defining the document representing the Schema. Used for + schemas other than Swagger/OpenAPI. + :vartype value: str + :ivar definitions: Types definitions. Used for Swagger/OpenAPI v1 schemas only, null otherwise. + :vartype definitions: any + :ivar components: Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null + otherwise. + :vartype components: any + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Json escaped string defining the document representing the Schema. Used for schemas other than + Swagger/OpenAPI.""" + definitions: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Types definitions. Used for Swagger/OpenAPI v1 schemas only, null otherwise.""" + components: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null otherwise.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + definitions: Optional[Any] = None, + components: Optional[Any] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SubscriptionContract(ProxyResource): + """Subscription details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Subscription contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.SubscriptionContractProperties + """ + + properties: Optional["_models.SubscriptionContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription contract properties.""" + + __flattened_items = [ + "owner_id", + "scope", + "display_name", + "state", + "created_date", + "start_date", + "expiration_date", + "end_date", + "notification_date", + "primary_key", + "secondary_key", + "state_comment", + "allow_tracing", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SubscriptionContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SubscriptionContractProperties(_Model): + """Subscription details. + + :ivar owner_id: The user resource identifier of the subscription owner. The value is a valid + relative URL in the format of /users/{userId} where {userId} is a user identifier. + :vartype owner_id: str + :ivar scope: Scope like /products/{productId} or /apis or /apis/{apiId}. Required. + :vartype scope: str + :ivar display_name: The name of the subscription, or null if the subscription has no name. + :vartype display_name: str + :ivar state: Subscription state. Possible states are * active – the subscription is active, * + suspended – the subscription is blocked, and the subscriber cannot call any APIs of the + product, * submitted – the subscription request has been made by the developer, but has not yet + been approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Required. Known values are: "suspended", "active", "expired", "submitted", "rejected", and + "cancelled". + :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState + :ivar created_date: Subscription creation date. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_date: ~datetime.datetime + :ivar start_date: Subscription activation date. The setting is for audit purposes only and the + subscription is not automatically activated. The subscription lifecycle can be managed by using + the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as + specified by the ISO 8601 standard. + :vartype start_date: ~datetime.datetime + :ivar expiration_date: Subscription expiration date. The setting is for audit purposes only and + the subscription is not automatically expired. The subscription lifecycle can be managed by + using the ``state`` property. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype expiration_date: ~datetime.datetime + :ivar end_date: Date when subscription was cancelled or expired. The setting is for audit + purposes only and the subscription is not automatically cancelled. The subscription lifecycle + can be managed by using the ``state`` property. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype end_date: ~datetime.datetime + :ivar notification_date: Upcoming subscription expiration notification date. The date conforms + to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype notification_date: ~datetime.datetime + :ivar primary_key: Subscription primary key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :vartype primary_key: str + :ivar secondary_key: Subscription secondary key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :vartype secondary_key: str + :ivar state_comment: Optional subscription comment added by an administrator when the state is + changed to the 'rejected'. + :vartype state_comment: str + :ivar allow_tracing: Determines whether tracing is enabled. + :vartype allow_tracing: bool + """ + + owner_id: Optional[str] = rest_field(name="ownerId", visibility=["read", "create", "update", "delete", "query"]) + """The user resource identifier of the subscription owner. The value is a valid relative URL in + the format of /users/{userId} where {userId} is a user identifier.""" + scope: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Scope like /products/{productId} or /apis or /apis/{apiId}. Required.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """The name of the subscription, or null if the subscription has no name.""" + state: Union[str, "_models.SubscriptionState"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription state. Possible states are * active – the subscription is active, * suspended – + the subscription is blocked, and the subscriber cannot call any APIs of the product, * + submitted – the subscription request has been made by the developer, but has not yet been + approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Required. Known values are: \"suspended\", \"active\", \"expired\", \"submitted\", + \"rejected\", and \"cancelled\".""" + created_date: Optional[datetime.datetime] = rest_field(name="createdDate", visibility=["read"], format="rfc3339") + """Subscription creation date. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` + as specified by the ISO 8601 standard.""" + start_date: Optional[datetime.datetime] = rest_field( + name="startDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Subscription activation date. The setting is for audit purposes only and the subscription is + not automatically activated. The subscription lifecycle can be managed by using the ``state`` + property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by + the ISO 8601 standard.""" + expiration_date: Optional[datetime.datetime] = rest_field( + name="expirationDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Subscription expiration date. The setting is for audit purposes only and the subscription is + not automatically expired. The subscription lifecycle can be managed by using the ``state`` + property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by + the ISO 8601 standard.""" + end_date: Optional[datetime.datetime] = rest_field( + name="endDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Date when subscription was cancelled or expired. The setting is for audit purposes only and the + subscription is not automatically cancelled. The subscription lifecycle can be managed by using + the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as + specified by the ISO 8601 standard.""" + notification_date: Optional[datetime.datetime] = rest_field( + name="notificationDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Upcoming subscription expiration notification date. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + primary_key: Optional[str] = rest_field( + name="primaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription primary key. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value.""" + secondary_key: Optional[str] = rest_field( + name="secondaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription secondary key. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value.""" + state_comment: Optional[str] = rest_field( + name="stateComment", visibility=["read", "create", "update", "delete", "query"] + ) + """Optional subscription comment added by an administrator when the state is changed to the + 'rejected'.""" + allow_tracing: Optional[bool] = rest_field( + name="allowTracing", visibility=["read", "create", "update", "delete", "query"] + ) + """Determines whether tracing is enabled.""" + + @overload + def __init__( + self, + *, + scope: str, + state: Union[str, "_models.SubscriptionState"], + owner_id: Optional[str] = None, + display_name: Optional[str] = None, + start_date: Optional[datetime.datetime] = None, + expiration_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + notification_date: Optional[datetime.datetime] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + state_comment: Optional[str] = None, + allow_tracing: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SubscriptionCreateParameterProperties(_Model): + """Parameters supplied to the Create subscription operation. + + :ivar owner_id: User (user id path) for whom subscription is being created in form + /users/{userId}. + :vartype owner_id: str + :ivar scope: Scope like /products/{productId} or /apis or /apis/{apiId}. Required. + :vartype scope: str + :ivar display_name: Subscription name. Required. + :vartype display_name: str + :ivar primary_key: Primary subscription key. If not specified during request key will be + generated automatically. + :vartype primary_key: str + :ivar secondary_key: Secondary subscription key. If not specified during request key will be + generated automatically. + :vartype secondary_key: str + :ivar state: Initial subscription state. If no value is specified, subscription is created with + Submitted state. Possible states are * active – the subscription is active, * suspended – the + subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – + the subscription request has been made by the developer, but has not yet been approved or + rejected, * rejected – the subscription request has been denied by an administrator, * + cancelled – the subscription has been cancelled by the developer or administrator, * expired – + the subscription reached its expiration date and was deactivated. Known values are: + "suspended", "active", "expired", "submitted", "rejected", and "cancelled". + :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState + :ivar allow_tracing: Determines whether tracing can be enabled. + :vartype allow_tracing: bool + """ + + owner_id: Optional[str] = rest_field(name="ownerId", visibility=["read", "create", "update", "delete", "query"]) + """User (user id path) for whom subscription is being created in form /users/{userId}.""" + scope: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Scope like /products/{productId} or /apis or /apis/{apiId}. Required.""" + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Subscription name. Required.""" + primary_key: Optional[str] = rest_field( + name="primaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Primary subscription key. If not specified during request key will be generated automatically.""" + secondary_key: Optional[str] = rest_field( + name="secondaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Secondary subscription key. If not specified during request key will be generated + automatically.""" + state: Optional[Union[str, "_models.SubscriptionState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Initial subscription state. If no value is specified, subscription is created with Submitted + state. Possible states are * active – the subscription is active, * suspended – the + subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – + the subscription request has been made by the developer, but has not yet been approved or + rejected, * rejected – the subscription request has been denied by an administrator, * + cancelled – the subscription has been cancelled by the developer or administrator, * expired – + the subscription reached its expiration date and was deactivated. Known values are: + \"suspended\", \"active\", \"expired\", \"submitted\", \"rejected\", and \"cancelled\".""" + allow_tracing: Optional[bool] = rest_field( + name="allowTracing", visibility=["read", "create", "update", "delete", "query"] + ) + """Determines whether tracing can be enabled.""" + + @overload + def __init__( + self, + *, + scope: str, + display_name: str, + owner_id: Optional[str] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + state: Optional[Union[str, "_models.SubscriptionState"]] = None, + allow_tracing: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SubscriptionCreateParameters(_Model): + """Subscription create details. + + :ivar properties: Subscription contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameterProperties + """ + + properties: Optional["_models.SubscriptionCreateParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription contract properties.""" + + __flattened_items = ["owner_id", "scope", "display_name", "primary_key", "secondary_key", "state", "allow_tracing"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SubscriptionCreateParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SubscriptionKeyParameterNamesContract(_Model): + """Subscription key parameter names details. + + :ivar header: Subscription key header name. + :vartype header: str + :ivar query: Subscription key query string parameter name. + :vartype query: str + """ + + header: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Subscription key header name.""" + query: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Subscription key query string parameter name.""" + + @overload + def __init__( + self, + *, + header: Optional[str] = None, + query: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SubscriptionKeysContract(_Model): + """Subscription keys. + + :ivar primary_key: Subscription primary key. + :vartype primary_key: str + :ivar secondary_key: Subscription secondary key. + :vartype secondary_key: str + """ + + primary_key: Optional[str] = rest_field( + name="primaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription primary key.""" + secondary_key: Optional[str] = rest_field( + name="secondaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription secondary key.""" + + @overload + def __init__( + self, + *, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SubscriptionsDelegationSettingsProperties(_Model): # pylint: disable=name-too-long + """Subscriptions delegation settings properties. + + :ivar enabled: Enable or disable delegation for subscriptions. + :vartype enabled: bool + """ + + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Enable or disable delegation for subscriptions.""" + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SubscriptionUpdateParameterProperties(_Model): + """Parameters supplied to the Update subscription operation. + + :ivar owner_id: User identifier path: /users/{userId}. + :vartype owner_id: str + :ivar scope: Scope like /products/{productId} or /apis or /apis/{apiId}. + :vartype scope: str + :ivar expiration_date: Subscription expiration date. The setting is for audit purposes only and + the subscription is not automatically expired. The subscription lifecycle can be managed by + using the ``state`` property. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype expiration_date: ~datetime.datetime + :ivar display_name: Subscription name. + :vartype display_name: str + :ivar primary_key: Primary subscription key. + :vartype primary_key: str + :ivar secondary_key: Secondary subscription key. + :vartype secondary_key: str + :ivar state: Subscription state. Possible states are * active – the subscription is active, * + suspended – the subscription is blocked, and the subscriber cannot call any APIs of the + product, * submitted – the subscription request has been made by the developer, but has not yet + been approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Known values are: "suspended", "active", "expired", "submitted", "rejected", and "cancelled". + :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState + :ivar state_comment: Comments describing subscription state change by the administrator when + the state is changed to the 'rejected'. + :vartype state_comment: str + :ivar allow_tracing: Determines whether tracing can be enabled. + :vartype allow_tracing: bool + """ + + owner_id: Optional[str] = rest_field(name="ownerId", visibility=["read", "create", "update", "delete", "query"]) + """User identifier path: /users/{userId}.""" + scope: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Scope like /products/{productId} or /apis or /apis/{apiId}.""" + expiration_date: Optional[datetime.datetime] = rest_field( + name="expirationDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Subscription expiration date. The setting is for audit purposes only and the subscription is + not automatically expired. The subscription lifecycle can be managed by using the ``state`` + property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by + the ISO 8601 standard.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription name.""" + primary_key: Optional[str] = rest_field( + name="primaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Primary subscription key.""" + secondary_key: Optional[str] = rest_field( + name="secondaryKey", visibility=["read", "create", "update", "delete", "query"] + ) + """Secondary subscription key.""" + state: Optional[Union[str, "_models.SubscriptionState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription state. Possible states are * active – the subscription is active, * suspended – + the subscription is blocked, and the subscriber cannot call any APIs of the product, * + submitted – the subscription request has been made by the developer, but has not yet been + approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Known values are: \"suspended\", \"active\", \"expired\", \"submitted\", \"rejected\", and + \"cancelled\".""" + state_comment: Optional[str] = rest_field( + name="stateComment", visibility=["read", "create", "update", "delete", "query"] + ) + """Comments describing subscription state change by the administrator when the state is changed to + the 'rejected'.""" + allow_tracing: Optional[bool] = rest_field( + name="allowTracing", visibility=["read", "create", "update", "delete", "query"] + ) + """Determines whether tracing can be enabled.""" + + @overload + def __init__( + self, + *, + owner_id: Optional[str] = None, + scope: Optional[str] = None, + expiration_date: Optional[datetime.datetime] = None, + display_name: Optional[str] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + state: Optional[Union[str, "_models.SubscriptionState"]] = None, + state_comment: Optional[str] = None, + allow_tracing: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SubscriptionUpdateParameters(_Model): + """Subscription update details. + + :ivar properties: Subscription Update contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameterProperties + """ + + properties: Optional["_models.SubscriptionUpdateParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription Update contract properties.""" + + __flattened_items = [ + "owner_id", + "scope", + "expiration_date", + "display_name", + "primary_key", + "secondary_key", + "state", + "state_comment", + "allow_tracing", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.SubscriptionUpdateParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + 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, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TagApiLinkContract(ProxyResource): + """Tag-API link details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Tag-API link entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.TagApiLinkContractProperties + """ + + properties: Optional["_models.TagApiLinkContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tag-API link entity contract properties.""" + + __flattened_items = ["api_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TagApiLinkContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TagApiLinkContractProperties(_Model): + """Tag-API link entity properties. + + :ivar api_id: Full resource Id of an API. Required. + :vartype api_id: str + """ + + api_id: str = rest_field(name="apiId", visibility=["read", "create", "update", "delete", "query"]) + """Full resource Id of an API. Required.""" + + @overload + def __init__( + self, + *, + api_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TagContract(ProxyResource): + """Tag Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Tag entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.TagContractProperties + """ + + properties: Optional["_models.TagContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tag entity contract properties.""" + + __flattened_items = ["display_name"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TagContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TagContractProperties(_Model): + """Tag contract Properties. + + :ivar display_name: Tag name. Required. + :vartype display_name: str + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Tag name. Required.""" + + @overload + def __init__( + self, + *, + display_name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TagCreateUpdateParameters(_Model): + """Parameters supplied to Create/Update Tag operations. + + :ivar properties: Properties supplied to Create Tag operation. + :vartype properties: ~azure.mgmt.apimanagement.models.TagContractProperties + """ + + properties: Optional["_models.TagContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties supplied to Create Tag operation.""" + + __flattened_items = ["display_name"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TagContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TagDescriptionBaseProperties(_Model): + """Parameters supplied to the Create TagDescription operation. + + :ivar description: Description of the Tag. + :vartype description: str + :ivar external_docs_url: Absolute URL of external resources describing the tag. + :vartype external_docs_url: str + :ivar external_docs_description: Description of the external resources describing the tag. + :vartype external_docs_description: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the Tag.""" + external_docs_url: Optional[str] = rest_field( + name="externalDocsUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """Absolute URL of external resources describing the tag.""" + external_docs_description: Optional[str] = rest_field( + name="externalDocsDescription", visibility=["read", "create", "update", "delete", "query"] + ) + """Description of the external resources describing the tag.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + external_docs_url: Optional[str] = None, + external_docs_description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TagDescriptionContract(ProxyResource): + """Contract details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: TagDescription entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.TagDescriptionContractProperties + """ + + properties: Optional["_models.TagDescriptionContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """TagDescription entity contract properties.""" + + __flattened_items = ["description", "external_docs_url", "external_docs_description", "tag_id", "display_name"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TagDescriptionContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TagDescriptionContractProperties(TagDescriptionBaseProperties): + """TagDescription contract Properties. + + :ivar description: Description of the Tag. + :vartype description: str + :ivar external_docs_url: Absolute URL of external resources describing the tag. + :vartype external_docs_url: str + :ivar external_docs_description: Description of the external resources describing the tag. + :vartype external_docs_description: str + :ivar tag_id: Identifier of the tag in the form of /tags/{tagId}. + :vartype tag_id: str + :ivar display_name: Tag name. + :vartype display_name: str + """ + + tag_id: Optional[str] = rest_field(name="tagId", visibility=["read", "create", "update", "delete", "query"]) + """Identifier of the tag in the form of /tags/{tagId}.""" + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Tag name.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + external_docs_url: Optional[str] = None, + external_docs_description: Optional[str] = None, + tag_id: Optional[str] = None, + display_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TagDescriptionCreateParameters(_Model): + """Parameters supplied to the Create TagDescription operation. + + :ivar properties: Properties supplied to Create TagDescription operation. + :vartype properties: ~azure.mgmt.apimanagement.models.TagDescriptionBaseProperties + """ + + properties: Optional["_models.TagDescriptionBaseProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties supplied to Create TagDescription operation.""" + + __flattened_items = ["description", "external_docs_url", "external_docs_description"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TagDescriptionBaseProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TagOperationLinkContract(ProxyResource): + """Tag-operation link details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Tag-API link entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.TagOperationLinkContractProperties + """ + + properties: Optional["_models.TagOperationLinkContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tag-API link entity contract properties.""" + + __flattened_items = ["operation_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TagOperationLinkContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TagOperationLinkContractProperties(_Model): + """Tag-operation link entity properties. + + :ivar operation_id: Full resource Id of an API operation. Required. + :vartype operation_id: str + """ + + operation_id: str = rest_field(name="operationId", visibility=["read", "create", "update", "delete", "query"]) + """Full resource Id of an API operation. Required.""" + + @overload + def __init__( + self, + *, + operation_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TagProductLinkContract(ProxyResource): + """Tag-product link details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Tag-API link entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.TagProductLinkContractProperties + """ + + properties: Optional["_models.TagProductLinkContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tag-API link entity contract properties.""" + + __flattened_items = ["product_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TagProductLinkContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TagProductLinkContractProperties(_Model): + """Tag-product link entity properties. + + :ivar product_id: Full resource Id of a product. Required. + :vartype product_id: str + """ + + product_id: str = rest_field(name="productId", visibility=["read", "create", "update", "delete", "query"]) + """Full resource Id of a product. Required.""" + + @overload + def __init__( + self, + *, + product_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TagResourceContract(_Model): + """TagResource contract properties. + + :ivar tag: Tag associated with the resource. Required. + :vartype tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties + :ivar api: API associated with the tag. + :vartype api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties + :ivar operation: Operation associated with the tag. + :vartype operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties + :ivar product: Product associated with the tag. + :vartype product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties + """ + + tag: "_models.TagResourceContractProperties" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Tag associated with the resource. Required.""" + api: Optional["_models.ApiTagResourceContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """API associated with the tag.""" + operation: Optional["_models.OperationTagResourceContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Operation associated with the tag.""" + product: Optional["_models.ProductTagResourceContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Product associated with the tag.""" + + @overload + def __init__( + self, + *, + tag: "_models.TagResourceContractProperties", + api: Optional["_models.ApiTagResourceContractProperties"] = None, + operation: Optional["_models.OperationTagResourceContractProperties"] = None, + product: Optional["_models.ProductTagResourceContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TagResourceContractProperties(_Model): + """Contract defining the Tag property in the Tag Resource Contract. + + :ivar id: Tag identifier. + :vartype id: str + :ivar name: Tag Name. + :vartype name: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Tag identifier.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Tag Name.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TenantConfigurationSyncStateContract(ProxyResource): + """Result of Tenant Configuration Sync State. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties returned Tenant Configuration Sync State check. + :vartype properties: + ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContractProperties + """ + + properties: Optional["_models.TenantConfigurationSyncStateContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties returned Tenant Configuration Sync State check.""" + + __flattened_items = [ + "branch", + "commit_id", + "is_export", + "is_synced", + "is_git_enabled", + "sync_date", + "configuration_change_date", + "last_operation_id", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TenantConfigurationSyncStateContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TenantConfigurationSyncStateContractProperties(_Model): # pylint: disable=name-too-long + """Tenant Configuration Synchronization State. + + :ivar branch: The name of Git branch. + :vartype branch: str + :ivar commit_id: The latest commit Id. + :vartype commit_id: str + :ivar is_export: value indicating if last sync was save (true) or deploy (false) operation. + :vartype is_export: bool + :ivar is_synced: value indicating if last synchronization was later than the configuration + change. + :vartype is_synced: bool + :ivar is_git_enabled: value indicating whether Git configuration access is enabled. + :vartype is_git_enabled: bool + :ivar sync_date: The date of the latest synchronization. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype sync_date: ~datetime.datetime + :ivar configuration_change_date: The date of the latest configuration change. The date conforms + to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype configuration_change_date: ~datetime.datetime + :ivar last_operation_id: Most recent tenant configuration operation identifier. + :vartype last_operation_id: str + """ + + branch: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of Git branch.""" + commit_id: Optional[str] = rest_field(name="commitId", visibility=["read", "create", "update", "delete", "query"]) + """The latest commit Id.""" + is_export: Optional[bool] = rest_field(name="isExport", visibility=["read", "create", "update", "delete", "query"]) + """value indicating if last sync was save (true) or deploy (false) operation.""" + is_synced: Optional[bool] = rest_field(name="isSynced", visibility=["read", "create", "update", "delete", "query"]) + """value indicating if last synchronization was later than the configuration change.""" + is_git_enabled: Optional[bool] = rest_field( + name="isGitEnabled", visibility=["read", "create", "update", "delete", "query"] + ) + """value indicating whether Git configuration access is enabled.""" + sync_date: Optional[datetime.datetime] = rest_field( + name="syncDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The date of the latest synchronization. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + configuration_change_date: Optional[datetime.datetime] = rest_field( + name="configurationChangeDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The date of the latest configuration change. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard.""" + last_operation_id: Optional[str] = rest_field( + name="lastOperationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Most recent tenant configuration operation identifier.""" + + @overload + def __init__( + self, + *, + branch: Optional[str] = None, + commit_id: Optional[str] = None, + is_export: Optional[bool] = None, + is_synced: Optional[bool] = None, + is_git_enabled: Optional[bool] = None, + sync_date: Optional[datetime.datetime] = None, + configuration_change_date: Optional[datetime.datetime] = None, + last_operation_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TenantSettingsContract(ProxyResource): + """Tenant Settings. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: TenantSettings entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.TenantSettingsContractProperties + """ + + properties: Optional["_models.TenantSettingsContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """TenantSettings entity contract properties.""" + + __flattened_items = ["settings"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.TenantSettingsContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class TenantSettingsContractProperties(_Model): + """Tenant access information contract of the API Management service. + + :ivar settings: Tenant settings. + :vartype settings: dict[str, str] + """ + + settings: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Tenant settings.""" + + @overload + def __init__( + self, + *, + settings: Optional[dict[str, str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TermsOfServiceProperties(_Model): + """Terms of service contract properties. + + :ivar text: A terms of service text. + :vartype text: str + :ivar enabled: Display terms of service during a sign-up process. + :vartype enabled: bool + :ivar consent_required: Ask user for consent to the terms of service. + :vartype consent_required: bool + """ + + text: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A terms of service text.""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Display terms of service during a sign-up process.""" + consent_required: Optional[bool] = rest_field( + name="consentRequired", visibility=["read", "create", "update", "delete", "query"] + ) + """Ask user for consent to the terms of service.""" + + @overload + def __init__( + self, + *, + text: Optional[str] = None, + enabled: Optional[bool] = None, + consent_required: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TokenBodyParameterContract(_Model): + """OAuth acquire token request body parameter (www-url-form-encoded). + + :ivar name: body parameter name. Required. + :vartype name: str + :ivar value: body parameter value. Required. + :vartype value: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """body parameter name. Required.""" + value: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """body parameter value. Required.""" + + @overload + def __init__( + self, + *, + name: str, + value: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ToolContract(ProxyResource): + """Tool details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Properties of the Tool Contract. + :vartype properties: ~azure.mgmt.apimanagement.models.ToolContractProperties + """ + + properties: Optional["_models.ToolContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the Tool Contract.""" + + __flattened_items = ["display_name", "description", "operation_id"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.ToolContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class ToolContractProperties(_Model): + """ToolContractProperties. + + :ivar display_name: Tool Name. MCP tool name must contain only letters, numbers, underscores, + and hyphens. + :vartype display_name: str + :ivar description: Description of the tool. + :vartype description: str + :ivar operation_id: Identifier of the operation this MCP tool is associated with in the form of + /apis/{apiId}/operations/{operationId}. + :vartype operation_id: str + """ + + display_name: Optional[str] = rest_field( + name="displayName", visibility=["read", "create", "update", "delete", "query"] + ) + """Tool Name. MCP tool name must contain only letters, numbers, underscores, and hyphens.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the tool.""" + operation_id: Optional[str] = rest_field( + name="operationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Identifier of the operation this MCP tool is associated with in the form of + /apis/{apiId}/operations/{operationId}.""" + + @overload + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + operation_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserAssignedIdentity(_Model): + """User assigned identity properties. + + :ivar principal_id: The principal ID of the assigned identity. + :vartype principal_id: str + :ivar client_id: The client ID of the assigned identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal ID of the assigned identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) + """The client ID of the assigned identity.""" + + +class UserContract(ProxyResource): + """User details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: User entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.UserContractProperties + """ + + properties: Optional["_models.UserContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """User entity contract properties.""" + + __flattened_items = [ + "state", + "note", + "identities", + "first_name", + "last_name", + "email", + "registration_date", + "groups", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.UserContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class UserEntityBaseParameters(_Model): + """User Entity Base Parameters set. + + :ivar state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Known values are: "active", "blocked", "pending", and "deleted". + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + """ + + state: Optional[Union[str, "_models.UserState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Account state. Specifies whether the user is active or not. Blocked users are unable to sign + into the developer portal or call any APIs of subscribed products. Default state is Active. + Known values are: \"active\", \"blocked\", \"pending\", and \"deleted\".""" + note: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional note about a user set by the administrator.""" + identities: Optional[list["_models.UserIdentityContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Collection of user identities.""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.UserState"]] = None, + note: Optional[str] = None, + identities: Optional[list["_models.UserIdentityContract"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserContractProperties(UserEntityBaseParameters): + """User profile. + + :ivar state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Known values are: "active", "blocked", "pending", and "deleted". + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar first_name: First name. + :vartype first_name: str + :ivar last_name: Last name. + :vartype last_name: str + :ivar email: Email address. + :vartype email: str + :ivar registration_date: Date of user registration. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype registration_date: ~datetime.datetime + :ivar groups: Collection of groups user is part of. + :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] + """ + + first_name: Optional[str] = rest_field(name="firstName", visibility=["read", "create", "update", "delete", "query"]) + """First name.""" + last_name: Optional[str] = rest_field(name="lastName", visibility=["read", "create", "update", "delete", "query"]) + """Last name.""" + email: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Email address.""" + registration_date: Optional[datetime.datetime] = rest_field( + name="registrationDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Date of user registration. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` + as specified by the ISO 8601 standard.""" + groups: Optional[list["_models.GroupContractProperties"]] = rest_field(visibility=["read"]) + """Collection of groups user is part of.""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.UserState"]] = None, + note: Optional[str] = None, + identities: Optional[list["_models.UserIdentityContract"]] = None, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + email: Optional[str] = None, + registration_date: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserCreateParameterProperties(UserEntityBaseParameters): + """Parameters supplied to the Create User operation. + + :ivar state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Known values are: "active", "blocked", "pending", and "deleted". + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar email: Email address. Must not be empty and must be unique within the service instance. + Required. + :vartype email: str + :ivar first_name: First name. Required. + :vartype first_name: str + :ivar last_name: Last name. Required. + :vartype last_name: str + :ivar password: User Password. If no value is provided, a default password is generated. + :vartype password: str + :ivar app_type: Determines the type of application which send the create user request. Default + is legacy portal. Known values are: "portal" and "developerPortal". + :vartype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :ivar confirmation: Determines the type of confirmation e-mail that will be sent to the newly + created user. Known values are: "signup" and "invite". + :vartype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation + """ + + email: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Email address. Must not be empty and must be unique within the service instance. Required.""" + first_name: str = rest_field(name="firstName", visibility=["read", "create", "update", "delete", "query"]) + """First name. Required.""" + last_name: str = rest_field(name="lastName", visibility=["read", "create", "update", "delete", "query"]) + """Last name. Required.""" + password: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """User Password. If no value is provided, a default password is generated.""" + app_type: Optional[Union[str, "_models.AppType"]] = rest_field( + name="appType", visibility=["read", "create", "update", "delete", "query"] + ) + """Determines the type of application which send the create user request. Default is legacy + portal. Known values are: \"portal\" and \"developerPortal\".""" + confirmation: Optional[Union[str, "_models.Confirmation"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Determines the type of confirmation e-mail that will be sent to the newly created user. Known + values are: \"signup\" and \"invite\".""" + + @overload + def __init__( + self, + *, + email: str, + first_name: str, + last_name: str, + state: Optional[Union[str, "_models.UserState"]] = None, + note: Optional[str] = None, + identities: Optional[list["_models.UserIdentityContract"]] = None, + password: Optional[str] = None, + app_type: Optional[Union[str, "_models.AppType"]] = None, + confirmation: Optional[Union[str, "_models.Confirmation"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserCreateParameters(_Model): + """User create details. + + :ivar properties: User entity create contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.UserCreateParameterProperties + """ + + properties: Optional["_models.UserCreateParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """User entity create contract properties.""" + + __flattened_items = [ + "state", + "note", + "identities", + "email", + "first_name", + "last_name", + "password", + "app_type", + "confirmation", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.UserCreateParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class UserIdentityContract(_Model): + """User identity details. + + :ivar provider: Identity provider name. + :vartype provider: str + :ivar id: Identifier value within provider. + :vartype id: str + """ + + provider: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identity provider name.""" + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Identifier value within provider.""" + + @overload + def __init__( + self, + *, + provider: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserIdentityProperties(_Model): + """UserIdentityProperties. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + principal_id: Optional[str] = rest_field( + name="principalId", visibility=["read", "create", "update", "delete", "query"] + ) + """The principal id of user assigned identity.""" + client_id: Optional[str] = rest_field(name="clientId", visibility=["read", "create", "update", "delete", "query"]) + """The client id of user assigned identity.""" + + @overload + def __init__( + self, + *, + principal_id: Optional[str] = None, + client_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserTokenParameterProperties(_Model): + """Parameters supplied to the Get User Token operation. + + :ivar key_type: The Key to be used to generate token for user. Required. Known values are: + "primary" and "secondary". + :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType + :ivar expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The + date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. Required. + :vartype expiry: ~datetime.datetime + """ + + key_type: Union[str, "_models.KeyType"] = rest_field( + name="keyType", visibility=["read", "create", "update", "delete", "query"] + ) + """The Key to be used to generate token for user. Required. Known values are: \"primary\" and + \"secondary\".""" + expiry: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc3339") + """The Expiry time of the Token. Maximum token expiry time is set to 30 days. The date conforms to + the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required.""" + + @overload + def __init__( + self, + *, + key_type: Union[str, "_models.KeyType"], + expiry: datetime.datetime, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserTokenParameters(_Model): + """Get User Token parameters. + + :ivar properties: User Token Parameter contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.UserTokenParameterProperties + """ + + properties: Optional["_models.UserTokenParameterProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """User Token Parameter contract properties.""" + + __flattened_items = ["key_type", "expiry"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.UserTokenParameterProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class UserTokenResult(_Model): + """Get User Token response details. + + :ivar value: Shared Access Authorization token for the User. + :vartype value: str + """ + + value: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Shared Access Authorization token for the User.""" + + @overload + def __init__( + self, + *, + value: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class UserUpdateParameters(_Model): + """User update parameters. + + :ivar properties: User entity update contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.UserUpdateParametersProperties + """ + + properties: Optional["_models.UserUpdateParametersProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """User entity update contract properties.""" + + __flattened_items = ["state", "note", "identities", "email", "password", "first_name", "last_name"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.UserUpdateParametersProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class UserUpdateParametersProperties(UserEntityBaseParameters): + """Parameters supplied to the Update User operation. + + :ivar state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Known values are: "active", "blocked", "pending", and "deleted". + :vartype state: str or ~azure.mgmt.apimanagement.models.UserState + :ivar note: Optional note about a user set by the administrator. + :vartype note: str + :ivar identities: Collection of user identities. + :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :ivar email: Email address. Must not be empty and must be unique within the service instance. + :vartype email: str + :ivar password: User Password. + :vartype password: str + :ivar first_name: First name. + :vartype first_name: str + :ivar last_name: Last name. + :vartype last_name: str + """ + + email: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Email address. Must not be empty and must be unique within the service instance.""" + password: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """User Password.""" + first_name: Optional[str] = rest_field(name="firstName", visibility=["read", "create", "update", "delete", "query"]) + """First name.""" + last_name: Optional[str] = rest_field(name="lastName", visibility=["read", "create", "update", "delete", "query"]) + """Last name.""" + + @overload + def __init__( + self, + *, + state: Optional[Union[str, "_models.UserState"]] = None, + note: Optional[str] = None, + identities: Optional[list["_models.UserIdentityContract"]] = None, + email: Optional[str] = None, + password: Optional[str] = None, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class VirtualNetworkConfiguration(_Model): + """Configuration of a virtual network to which API Management service is deployed. + + :ivar vnetid: The virtual network ID. This is typically a GUID. Expect a null GUID by default. + :vartype vnetid: str + :ivar subnetname: The name of the subnet. + :vartype subnetname: str + :ivar subnet_resource_id: The full resource ID of a subnet in a virtual network to deploy the + API Management service in. + :vartype subnet_resource_id: str + """ + + vnetid: Optional[str] = rest_field(visibility=["read"]) + """The virtual network ID. This is typically a GUID. Expect a null GUID by default.""" + subnetname: Optional[str] = rest_field(visibility=["read"]) + """The name of the subnet.""" + subnet_resource_id: Optional[str] = rest_field( + name="subnetResourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The full resource ID of a subnet in a virtual network to deploy the API Management service in.""" + + @overload + def __init__( + self, + *, + subnet_resource_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WikiContract(ProxyResource): + """Wiki properties. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Wiki details. + :vartype properties: ~azure.mgmt.apimanagement.models.WikiContractProperties + """ + + properties: Optional["_models.WikiContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Wiki details.""" + + __flattened_items = ["documents"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.WikiContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class WikiContractProperties(_Model): + """Wiki contract details. + + :ivar documents: Collection wiki documents included into this wiki. + :vartype documents: list[~azure.mgmt.apimanagement.models.WikiDocumentationContract] + """ + + documents: Optional[list["_models.WikiDocumentationContract"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Collection wiki documents included into this wiki.""" + + @overload + def __init__( + self, + *, + documents: Optional[list["_models.WikiDocumentationContract"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WikiDocumentationContract(_Model): + """Wiki documentation details. + + :ivar documentation_id: Documentation Identifier. + :vartype documentation_id: str + """ + + documentation_id: Optional[str] = rest_field( + name="documentationId", visibility=["read", "create", "update", "delete", "query"] + ) + """Documentation Identifier.""" + + @overload + def __init__( + self, + *, + documentation_id: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WikiUpdateContract(_Model): + """Wiki update contract details. + + :ivar properties: Wiki details. + :vartype properties: ~azure.mgmt.apimanagement.models.WikiContractProperties + """ + + properties: Optional["_models.WikiContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Wiki details.""" + + __flattened_items = ["documents"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.WikiContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class WorkspaceContract(ProxyResource): + """Workspace details. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :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 system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.apimanagement.models.SystemData + :ivar properties: Workspace entity contract properties. + :vartype properties: ~azure.mgmt.apimanagement.models.WorkspaceContractProperties + """ + + properties: Optional["_models.WorkspaceContractProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Workspace entity contract properties.""" + + __flattened_items = ["display_name", "description"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.WorkspaceContractProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class WorkspaceContractProperties(_Model): + """Workspace entity properties. + + :ivar display_name: Name of the workspace. Required. + :vartype display_name: str + :ivar description: Description of the workspace. + :vartype description: str + """ + + display_name: str = rest_field(name="displayName", visibility=["read", "create", "update", "delete", "query"]) + """Name of the workspace. Required.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Description of the workspace.""" + + @overload + def __init__( + self, + *, + display_name: str, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class WorkspaceLinksGateway(_Model): + """WorkspaceLinksGateway. + + :ivar id: The link to the API Management gateway. + :vartype id: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The link to the API Management gateway.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class X509CertificateName(_Model): + """Properties of server X509Names. + + :ivar name: Common Name of the Certificate. + :vartype name: str + :ivar issuer_certificate_thumbprint: Thumbprint for the Issuer of the Certificate. + :vartype issuer_certificate_thumbprint: str + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Common Name of the Certificate.""" + issuer_certificate_thumbprint: Optional[str] = rest_field( + name="issuerCertificateThumbprint", visibility=["read", "create", "update", "delete", "query"] + ) + """Thumbprint for the Issuer of the Certificate.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + issuer_certificate_thumbprint: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) 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 deleted file mode 100644 index ae0e034c40b4..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py +++ /dev/null @@ -1,22977 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import datetime -import sys -from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union - -from .. import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object - - -class AccessInformationCollection(_serialization.Model): - """Paged AccessInformation list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.AccessInformationContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[AccessInformationContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - 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 - """ - - _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"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. - - 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 - """ - - -class AccessInformationContract(ProxyResource): - """Tenant Settings. - - 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 id_properties_id: Access Information type ('access' or 'gitAccess'). - :vartype id_properties_id: str - :ivar principal_id: Principal (User) Identifier. - :vartype principal_id: str - :ivar enabled: Determines whether direct access is enabled. - :vartype enabled: 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"}, - "id_properties_id": {"key": "properties.id", "type": "str"}, - "principal_id": {"key": "properties.principalId", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__( - self, - *, - id_properties_id: Optional[str] = None, - principal_id: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id_properties_id: Access Information type ('access' or 'gitAccess'). - :paramtype id_properties_id: str - :keyword principal_id: Principal (User) Identifier. - :paramtype principal_id: str - :keyword enabled: Determines whether direct access is enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.id_properties_id = id_properties_id - self.principal_id = principal_id - self.enabled = enabled - - -class AccessInformationCreateParameters(_serialization.Model): - """Tenant access information update parameters. - - :ivar principal_id: Principal (User) Identifier. - :vartype principal_id: str - :ivar primary_key: Primary access key. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :vartype primary_key: str - :ivar secondary_key: Secondary access key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :vartype secondary_key: str - :ivar enabled: Determines whether direct access is enabled. - :vartype enabled: bool - """ - - _attribute_map = { - "principal_id": {"key": "properties.principalId", "type": "str"}, - "primary_key": {"key": "properties.primaryKey", "type": "str"}, - "secondary_key": {"key": "properties.secondaryKey", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__( - self, - *, - principal_id: Optional[str] = None, - primary_key: Optional[str] = None, - secondary_key: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword principal_id: Principal (User) Identifier. - :paramtype principal_id: str - :keyword primary_key: Primary access key. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :paramtype primary_key: str - :keyword secondary_key: Secondary access key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :paramtype secondary_key: str - :keyword enabled: Determines whether direct access is enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.primary_key = primary_key - self.secondary_key = secondary_key - self.enabled = enabled - - -class AccessInformationSecretsContract(_serialization.Model): - """Tenant access information contract of the API Management service. - - :ivar id: Access Information type ('access' or 'gitAccess'). - :vartype id: str - :ivar principal_id: Principal (User) Identifier. - :vartype principal_id: str - :ivar primary_key: Primary access key. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :vartype primary_key: str - :ivar secondary_key: Secondary access key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :vartype secondary_key: str - :ivar enabled: Determines whether direct access is enabled. - :vartype enabled: bool - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "primary_key": {"key": "primaryKey", "type": "str"}, - "secondary_key": {"key": "secondaryKey", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - principal_id: Optional[str] = None, - primary_key: Optional[str] = None, - secondary_key: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Access Information type ('access' or 'gitAccess'). - :paramtype id: str - :keyword principal_id: Principal (User) Identifier. - :paramtype principal_id: str - :keyword primary_key: Primary access key. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :paramtype primary_key: str - :keyword secondary_key: Secondary access key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :paramtype secondary_key: str - :keyword enabled: Determines whether direct access is enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.id = id - self.principal_id = principal_id - self.primary_key = primary_key - self.secondary_key = secondary_key - self.enabled = enabled - - -class AccessInformationUpdateParameters(_serialization.Model): - """Tenant access information update parameters. - - :ivar enabled: Determines whether direct access is enabled. - :vartype enabled: bool - """ - - _attribute_map = { - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Determines whether direct access is enabled. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.enabled = enabled - - -class AdditionalLocation(_serialization.Model): - """Description of an additional API Management resource location. - - 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 location: The location name of the additional region among Azure Data center regions. - Required. - :vartype location: str - :ivar sku: SKU properties of the API Management service. Required. - :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :ivar zones: A list of availability zones denoting where the resource needs to come from. - :vartype zones: list[str] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in the additional location. Available only for Basic, Standard, Premium and Isolated - SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service which is deployed in an Internal Virtual Network in a particular additional location. - Available only for Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the location. Supported only for Premium SKU being deployed - in Virtual Network. - :vartype public_ip_address_id: str - :ivar virtual_network_configuration: Virtual network configuration for the location. - :vartype virtual_network_configuration: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :ivar gateway_regional_url: Gateway URL of the API Management service in the Region. - :vartype gateway_regional_url: str - :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT - Gateway deployed service. Available only for Premium SKU on stv2 platform. - :vartype outbound_public_ip_addresses: list[str] - :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple - 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", "mtv1", and "stv2.1". - :vartype platform_version: str or ~azure.mgmt.apimanagement.models.PlatformVersion - """ - - _validation = { - "location": {"required": True}, - "sku": {"required": True}, - "public_ip_addresses": {"readonly": True}, - "private_ip_addresses": {"readonly": True}, - "gateway_regional_url": {"readonly": True}, - "outbound_public_ip_addresses": {"readonly": True}, - "platform_version": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "ApiManagementServiceSkuProperties"}, - "zones": {"key": "zones", "type": "[str]"}, - "public_ip_addresses": {"key": "publicIPAddresses", "type": "[str]"}, - "private_ip_addresses": {"key": "privateIPAddresses", "type": "[str]"}, - "public_ip_address_id": {"key": "publicIpAddressId", "type": "str"}, - "virtual_network_configuration": {"key": "virtualNetworkConfiguration", "type": "VirtualNetworkConfiguration"}, - "gateway_regional_url": {"key": "gatewayRegionalUrl", "type": "str"}, - "nat_gateway_state": {"key": "natGatewayState", "type": "str"}, - "outbound_public_ip_addresses": {"key": "outboundPublicIPAddresses", "type": "[str]"}, - "disable_gateway": {"key": "disableGateway", "type": "bool"}, - "platform_version": {"key": "platformVersion", "type": "str"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.ApiManagementServiceSkuProperties", - zones: Optional[List[str]] = None, - public_ip_address_id: Optional[str] = None, - virtual_network_configuration: Optional["_models.VirtualNetworkConfiguration"] = None, - nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, - disable_gateway: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword location: The location name of the additional region among Azure Data center regions. - Required. - :paramtype location: str - :keyword sku: SKU properties of the API Management service. Required. - :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :keyword zones: A list of availability zones denoting where the resource needs to come from. - :paramtype zones: list[str] - :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the location. Supported only for Premium SKU being deployed - in Virtual Network. - :paramtype public_ip_address_id: str - :keyword virtual_network_configuration: Virtual network configuration for the location. - :paramtype virtual_network_configuration: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :keyword nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :paramtype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :keyword disable_gateway: Property only valid for an Api Management service deployed in - multiple locations. This can be used to disable the gateway in this additional location. - :paramtype disable_gateway: bool - """ - super().__init__(**kwargs) - self.location = location - self.sku = sku - self.zones = zones - self.public_ip_addresses = None - self.private_ip_addresses = None - self.public_ip_address_id = public_ip_address_id - self.virtual_network_configuration = virtual_network_configuration - self.gateway_regional_url = None - self.nat_gateway_state = nat_gateway_state - self.outbound_public_ip_addresses = None - self.disable_gateway = disable_gateway - 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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ApiContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ApiContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class ApiContactInformation(_serialization.Model): - """API contact information. - - :ivar name: The identifying name of the contact person/organization. - :vartype name: str - :ivar url: The URL pointing to the contact information. MUST be in the format of a URL. - :vartype url: str - :ivar email: The email address of the contact person/organization. MUST be in the format of an - email address. - :vartype email: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "url": {"key": "url", "type": "str"}, - "email": {"key": "email", "type": "str"}, - } - - def __init__( - self, *, name: Optional[str] = None, url: Optional[str] = None, email: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The identifying name of the contact person/organization. - :paramtype name: str - :keyword url: The URL pointing to the contact information. MUST be in the format of a URL. - :paramtype url: str - :keyword email: The email address of the contact person/organization. MUST be in the format of - an email address. - :paramtype email: str - """ - super().__init__(**kwargs) - self.name = name - self.url = url - self.email = email - - -class ApiContract(ProxyResource): - """API 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 description: Description of the API. May include HTML formatting tags. - :vartype description: str - :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :vartype api_revision: str - :ivar api_version: Indicates the version identifier of the API if the API is versioned. - :vartype api_version: str - :ivar is_current: Indicates if API revision is current api revision. - :vartype is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :ivar api_revision_description: Description of the API Revision. - :vartype api_revision_description: str - :ivar api_version_description: Description of the API Version. - :vartype api_version_description: str - :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. - :vartype api_version_set_id: str - :ivar subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :vartype subscription_required: bool - :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of - a URL. - :vartype terms_of_service_url: str - :ivar contact: Contact information for the API. - :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :ivar license: License information for the API. - :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :ivar source_api_id: API identifier of the source API. - :vartype source_api_id: str - :ivar display_name: API name. Must be 1 to 300 characters long. - :vartype display_name: str - :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :vartype service_url: str - :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the - API Management service instance. It is appended to the API endpoint base URL specified during - the service instance creation to form a public URL for this API. - :vartype path: str - :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :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 = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "api_revision": {"max_length": 100, "min_length": 1}, - "api_version": {"max_length": 100}, - "is_online": {"readonly": True}, - "api_revision_description": {"max_length": 256}, - "api_version_description": {"max_length": 256}, - "display_name": {"max_length": 300, "min_length": 1}, - "service_url": {"max_length": 2000}, - "path": {"max_length": 400}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "authentication_settings": { - "key": "properties.authenticationSettings", - "type": "AuthenticationSettingsContract", - }, - "subscription_key_parameter_names": { - "key": "properties.subscriptionKeyParameterNames", - "type": "SubscriptionKeyParameterNamesContract", - }, - "api_type": {"key": "properties.type", "type": "str"}, - "api_revision": {"key": "properties.apiRevision", "type": "str"}, - "api_version": {"key": "properties.apiVersion", "type": "str"}, - "is_current": {"key": "properties.isCurrent", "type": "bool"}, - "is_online": {"key": "properties.isOnline", "type": "bool"}, - "api_revision_description": {"key": "properties.apiRevisionDescription", "type": "str"}, - "api_version_description": {"key": "properties.apiVersionDescription", "type": "str"}, - "api_version_set_id": {"key": "properties.apiVersionSetId", "type": "str"}, - "subscription_required": {"key": "properties.subscriptionRequired", "type": "bool"}, - "terms_of_service_url": {"key": "properties.termsOfServiceUrl", "type": "str"}, - "contact": {"key": "properties.contact", "type": "ApiContactInformation"}, - "license": {"key": "properties.license", "type": "ApiLicenseInformation"}, - "source_api_id": {"key": "properties.sourceApiId", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "service_url": {"key": "properties.serviceUrl", "type": "str"}, - "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 - self, - *, - description: Optional[str] = None, - authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "_models.ApiType"]] = None, - api_revision: Optional[str] = None, - api_version: Optional[str] = None, - is_current: Optional[bool] = None, - api_revision_description: Optional[str] = None, - api_version_description: Optional[str] = None, - api_version_set_id: Optional[str] = None, - subscription_required: Optional[bool] = None, - terms_of_service_url: Optional[str] = None, - contact: Optional["_models.ApiContactInformation"] = None, - license: Optional["_models.ApiLicenseInformation"] = None, - source_api_id: Optional[str] = None, - display_name: Optional[str] = None, - service_url: Optional[str] = None, - path: Optional[str] = None, - protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, - api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the API. May include HTML formatting tags. - :paramtype description: str - :keyword authentication_settings: Collection of authentication settings included into this API. - :paramtype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :paramtype api_revision: str - :keyword api_version: Indicates the version identifier of the API if the API is versioned. - :paramtype api_version: str - :keyword is_current: Indicates if API revision is current api revision. - :paramtype is_current: bool - :keyword api_revision_description: Description of the API Revision. - :paramtype api_revision_description: str - :keyword api_version_description: Description of the API Version. - :paramtype api_version_description: str - :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. - :paramtype api_version_set_id: str - :keyword subscription_required: Specifies whether an API or Product subscription is required - for accessing the API. - :paramtype subscription_required: bool - :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format - of a URL. - :paramtype terms_of_service_url: str - :keyword contact: Contact information for the API. - :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :keyword license: License information for the API. - :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :keyword source_api_id: API identifier of the source API. - :paramtype source_api_id: str - :keyword display_name: API name. Must be 1 to 300 characters long. - :paramtype display_name: str - :keyword service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :paramtype service_url: str - :keyword path: Relative URL uniquely identifying this API and all of its resource paths within - the API Management service instance. It is appended to the API endpoint base URL specified - during the service instance creation to form a public URL for this API. - :paramtype path: str - :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :keyword api_version_set: Version set details. - :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails - """ - super().__init__(**kwargs) - self.description = description - self.authentication_settings = authentication_settings - self.subscription_key_parameter_names = subscription_key_parameter_names - self.api_type = api_type - self.api_revision = api_revision - self.api_version = api_version - self.is_current = is_current - self.is_online = None - self.api_revision_description = api_revision_description - self.api_version_description = api_version_description - self.api_version_set_id = api_version_set_id - self.subscription_required = subscription_required - self.terms_of_service_url = terms_of_service_url - self.contact = contact - self.license = license - self.source_api_id = source_api_id - self.display_name = display_name - self.service_url = service_url - self.path = path - self.protocols = protocols - self.api_version_set = api_version_set - self.provisioning_state = None - - -class ApiEntityBaseContract(_serialization.Model): - """API base contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the API. May include HTML formatting tags. - :vartype description: str - :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :vartype api_revision: str - :ivar api_version: Indicates the version identifier of the API if the API is versioned. - :vartype api_version: str - :ivar is_current: Indicates if API revision is current api revision. - :vartype is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :ivar api_revision_description: Description of the API Revision. - :vartype api_revision_description: str - :ivar api_version_description: Description of the API Version. - :vartype api_version_description: str - :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. - :vartype api_version_set_id: str - :ivar subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :vartype subscription_required: bool - :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of - a URL. - :vartype terms_of_service_url: str - :ivar contact: Contact information for the API. - :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :ivar license: License information for the API. - :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - """ - - _validation = { - "api_revision": {"max_length": 100, "min_length": 1}, - "api_version": {"max_length": 100}, - "is_online": {"readonly": True}, - "api_revision_description": {"max_length": 256}, - "api_version_description": {"max_length": 256}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "authentication_settings": {"key": "authenticationSettings", "type": "AuthenticationSettingsContract"}, - "subscription_key_parameter_names": { - "key": "subscriptionKeyParameterNames", - "type": "SubscriptionKeyParameterNamesContract", - }, - "api_type": {"key": "type", "type": "str"}, - "api_revision": {"key": "apiRevision", "type": "str"}, - "api_version": {"key": "apiVersion", "type": "str"}, - "is_current": {"key": "isCurrent", "type": "bool"}, - "is_online": {"key": "isOnline", "type": "bool"}, - "api_revision_description": {"key": "apiRevisionDescription", "type": "str"}, - "api_version_description": {"key": "apiVersionDescription", "type": "str"}, - "api_version_set_id": {"key": "apiVersionSetId", "type": "str"}, - "subscription_required": {"key": "subscriptionRequired", "type": "bool"}, - "terms_of_service_url": {"key": "termsOfServiceUrl", "type": "str"}, - "contact": {"key": "contact", "type": "ApiContactInformation"}, - "license": {"key": "license", "type": "ApiLicenseInformation"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "_models.ApiType"]] = None, - api_revision: Optional[str] = None, - api_version: Optional[str] = None, - is_current: Optional[bool] = None, - api_revision_description: Optional[str] = None, - api_version_description: Optional[str] = None, - api_version_set_id: Optional[str] = None, - subscription_required: Optional[bool] = None, - terms_of_service_url: Optional[str] = None, - contact: Optional["_models.ApiContactInformation"] = None, - license: Optional["_models.ApiLicenseInformation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the API. May include HTML formatting tags. - :paramtype description: str - :keyword authentication_settings: Collection of authentication settings included into this API. - :paramtype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :paramtype api_revision: str - :keyword api_version: Indicates the version identifier of the API if the API is versioned. - :paramtype api_version: str - :keyword is_current: Indicates if API revision is current api revision. - :paramtype is_current: bool - :keyword api_revision_description: Description of the API Revision. - :paramtype api_revision_description: str - :keyword api_version_description: Description of the API Version. - :paramtype api_version_description: str - :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. - :paramtype api_version_set_id: str - :keyword subscription_required: Specifies whether an API or Product subscription is required - for accessing the API. - :paramtype subscription_required: bool - :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format - of a URL. - :paramtype terms_of_service_url: str - :keyword contact: Contact information for the API. - :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :keyword license: License information for the API. - :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - """ - super().__init__(**kwargs) - self.description = description - self.authentication_settings = authentication_settings - self.subscription_key_parameter_names = subscription_key_parameter_names - self.api_type = api_type - self.api_revision = api_revision - self.api_version = api_version - self.is_current = is_current - self.is_online = None - self.api_revision_description = api_revision_description - self.api_version_description = api_version_description - self.api_version_set_id = api_version_set_id - self.subscription_required = subscription_required - self.terms_of_service_url = terms_of_service_url - self.contact = contact - self.license = license - - -class ApiContractProperties(ApiEntityBaseContract): - """API Entity 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 description: Description of the API. May include HTML formatting tags. - :vartype description: str - :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :vartype api_revision: str - :ivar api_version: Indicates the version identifier of the API if the API is versioned. - :vartype api_version: str - :ivar is_current: Indicates if API revision is current api revision. - :vartype is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :ivar api_revision_description: Description of the API Revision. - :vartype api_revision_description: str - :ivar api_version_description: Description of the API Version. - :vartype api_version_description: str - :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. - :vartype api_version_set_id: str - :ivar subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :vartype subscription_required: bool - :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of - a URL. - :vartype terms_of_service_url: str - :ivar contact: Contact information for the API. - :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :ivar license: License information for the API. - :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :ivar source_api_id: API identifier of the source API. - :vartype source_api_id: str - :ivar display_name: API name. Must be 1 to 300 characters long. - :vartype display_name: str - :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :vartype service_url: str - :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the - API Management service instance. It is appended to the API endpoint base URL specified during - the service instance creation to form a public URL for this API. Required. - :vartype path: str - :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :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 = { - "api_revision": {"max_length": 100, "min_length": 1}, - "api_version": {"max_length": 100}, - "is_online": {"readonly": True}, - "api_revision_description": {"max_length": 256}, - "api_version_description": {"max_length": 256}, - "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 = { - "description": {"key": "description", "type": "str"}, - "authentication_settings": {"key": "authenticationSettings", "type": "AuthenticationSettingsContract"}, - "subscription_key_parameter_names": { - "key": "subscriptionKeyParameterNames", - "type": "SubscriptionKeyParameterNamesContract", - }, - "api_type": {"key": "type", "type": "str"}, - "api_revision": {"key": "apiRevision", "type": "str"}, - "api_version": {"key": "apiVersion", "type": "str"}, - "is_current": {"key": "isCurrent", "type": "bool"}, - "is_online": {"key": "isOnline", "type": "bool"}, - "api_revision_description": {"key": "apiRevisionDescription", "type": "str"}, - "api_version_description": {"key": "apiVersionDescription", "type": "str"}, - "api_version_set_id": {"key": "apiVersionSetId", "type": "str"}, - "subscription_required": {"key": "subscriptionRequired", "type": "bool"}, - "terms_of_service_url": {"key": "termsOfServiceUrl", "type": "str"}, - "contact": {"key": "contact", "type": "ApiContactInformation"}, - "license": {"key": "license", "type": "ApiLicenseInformation"}, - "source_api_id": {"key": "sourceApiId", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "service_url": {"key": "serviceUrl", "type": "str"}, - "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__( - self, - *, - path: str, - description: Optional[str] = None, - authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "_models.ApiType"]] = None, - api_revision: Optional[str] = None, - api_version: Optional[str] = None, - is_current: Optional[bool] = None, - api_revision_description: Optional[str] = None, - api_version_description: Optional[str] = None, - api_version_set_id: Optional[str] = None, - subscription_required: Optional[bool] = None, - terms_of_service_url: Optional[str] = None, - contact: Optional["_models.ApiContactInformation"] = None, - license: Optional["_models.ApiLicenseInformation"] = None, - source_api_id: Optional[str] = None, - display_name: Optional[str] = None, - service_url: Optional[str] = None, - protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, - api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the API. May include HTML formatting tags. - :paramtype description: str - :keyword authentication_settings: Collection of authentication settings included into this API. - :paramtype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :paramtype api_revision: str - :keyword api_version: Indicates the version identifier of the API if the API is versioned. - :paramtype api_version: str - :keyword is_current: Indicates if API revision is current api revision. - :paramtype is_current: bool - :keyword api_revision_description: Description of the API Revision. - :paramtype api_revision_description: str - :keyword api_version_description: Description of the API Version. - :paramtype api_version_description: str - :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. - :paramtype api_version_set_id: str - :keyword subscription_required: Specifies whether an API or Product subscription is required - for accessing the API. - :paramtype subscription_required: bool - :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format - of a URL. - :paramtype terms_of_service_url: str - :keyword contact: Contact information for the API. - :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :keyword license: License information for the API. - :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :keyword source_api_id: API identifier of the source API. - :paramtype source_api_id: str - :keyword display_name: API name. Must be 1 to 300 characters long. - :paramtype display_name: str - :keyword service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :paramtype service_url: str - :keyword path: Relative URL uniquely identifying this API and all of its resource paths within - the API Management service instance. It is appended to the API endpoint base URL specified - during the service instance creation to form a public URL for this API. Required. - :paramtype path: str - :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :keyword api_version_set: Version set details. - :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails - """ - super().__init__( - description=description, - authentication_settings=authentication_settings, - subscription_key_parameter_names=subscription_key_parameter_names, - api_type=api_type, - api_revision=api_revision, - api_version=api_version, - is_current=is_current, - api_revision_description=api_revision_description, - api_version_description=api_version_description, - api_version_set_id=api_version_set_id, - subscription_required=subscription_required, - terms_of_service_url=terms_of_service_url, - contact=contact, - license=license, - **kwargs - ) - self.source_api_id = source_api_id - self.display_name = display_name - self.service_url = service_url - self.path = path - self.protocols = protocols - self.api_version_set = api_version_set - self.provisioning_state = None - - -class ApiContractUpdateProperties(ApiEntityBaseContract): - """API update contract properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the API. May include HTML formatting tags. - :vartype description: str - :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :vartype api_revision: str - :ivar api_version: Indicates the version identifier of the API if the API is versioned. - :vartype api_version: str - :ivar is_current: Indicates if API revision is current api revision. - :vartype is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :ivar api_revision_description: Description of the API Revision. - :vartype api_revision_description: str - :ivar api_version_description: Description of the API Version. - :vartype api_version_description: str - :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. - :vartype api_version_set_id: str - :ivar subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :vartype subscription_required: bool - :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of - a URL. - :vartype terms_of_service_url: str - :ivar contact: Contact information for the API. - :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :ivar license: License information for the API. - :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :ivar display_name: API name. - :vartype display_name: str - :ivar service_url: Absolute URL of the backend service implementing this API. - :vartype service_url: str - :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the - API Management service instance. It is appended to the API endpoint base URL specified during - the service instance creation to form a public URL for this API. - :vartype path: str - :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - """ - - _validation = { - "api_revision": {"max_length": 100, "min_length": 1}, - "api_version": {"max_length": 100}, - "is_online": {"readonly": True}, - "api_revision_description": {"max_length": 256}, - "api_version_description": {"max_length": 256}, - "display_name": {"max_length": 300, "min_length": 1}, - "service_url": {"max_length": 2000, "min_length": 1}, - "path": {"max_length": 400}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "authentication_settings": {"key": "authenticationSettings", "type": "AuthenticationSettingsContract"}, - "subscription_key_parameter_names": { - "key": "subscriptionKeyParameterNames", - "type": "SubscriptionKeyParameterNamesContract", - }, - "api_type": {"key": "type", "type": "str"}, - "api_revision": {"key": "apiRevision", "type": "str"}, - "api_version": {"key": "apiVersion", "type": "str"}, - "is_current": {"key": "isCurrent", "type": "bool"}, - "is_online": {"key": "isOnline", "type": "bool"}, - "api_revision_description": {"key": "apiRevisionDescription", "type": "str"}, - "api_version_description": {"key": "apiVersionDescription", "type": "str"}, - "api_version_set_id": {"key": "apiVersionSetId", "type": "str"}, - "subscription_required": {"key": "subscriptionRequired", "type": "bool"}, - "terms_of_service_url": {"key": "termsOfServiceUrl", "type": "str"}, - "contact": {"key": "contact", "type": "ApiContactInformation"}, - "license": {"key": "license", "type": "ApiLicenseInformation"}, - "display_name": {"key": "displayName", "type": "str"}, - "service_url": {"key": "serviceUrl", "type": "str"}, - "path": {"key": "path", "type": "str"}, - "protocols": {"key": "protocols", "type": "[str]"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "_models.ApiType"]] = None, - api_revision: Optional[str] = None, - api_version: Optional[str] = None, - is_current: Optional[bool] = None, - api_revision_description: Optional[str] = None, - api_version_description: Optional[str] = None, - api_version_set_id: Optional[str] = None, - subscription_required: Optional[bool] = None, - terms_of_service_url: Optional[str] = None, - contact: Optional["_models.ApiContactInformation"] = None, - license: Optional["_models.ApiLicenseInformation"] = None, - display_name: Optional[str] = None, - service_url: Optional[str] = None, - path: Optional[str] = None, - protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the API. May include HTML formatting tags. - :paramtype description: str - :keyword authentication_settings: Collection of authentication settings included into this API. - :paramtype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :paramtype api_revision: str - :keyword api_version: Indicates the version identifier of the API if the API is versioned. - :paramtype api_version: str - :keyword is_current: Indicates if API revision is current api revision. - :paramtype is_current: bool - :keyword api_revision_description: Description of the API Revision. - :paramtype api_revision_description: str - :keyword api_version_description: Description of the API Version. - :paramtype api_version_description: str - :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. - :paramtype api_version_set_id: str - :keyword subscription_required: Specifies whether an API or Product subscription is required - for accessing the API. - :paramtype subscription_required: bool - :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format - of a URL. - :paramtype terms_of_service_url: str - :keyword contact: Contact information for the API. - :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :keyword license: License information for the API. - :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :keyword display_name: API name. - :paramtype display_name: str - :keyword service_url: Absolute URL of the backend service implementing this API. - :paramtype service_url: str - :keyword path: Relative URL uniquely identifying this API and all of its resource paths within - the API Management service instance. It is appended to the API endpoint base URL specified - during the service instance creation to form a public URL for this API. - :paramtype path: str - :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - """ - super().__init__( - description=description, - authentication_settings=authentication_settings, - subscription_key_parameter_names=subscription_key_parameter_names, - api_type=api_type, - api_revision=api_revision, - api_version=api_version, - is_current=is_current, - api_revision_description=api_revision_description, - api_version_description=api_version_description, - api_version_set_id=api_version_set_id, - subscription_required=subscription_required, - terms_of_service_url=terms_of_service_url, - contact=contact, - license=license, - **kwargs - ) - self.display_name = display_name - self.service_url = service_url - self.path = path - self.protocols = protocols - - -class ApiCreateOrUpdateParameter(_serialization.Model): - """API Create or Update Parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the API. May include HTML formatting tags. - :vartype description: str - :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :vartype api_revision: str - :ivar api_version: Indicates the version identifier of the API if the API is versioned. - :vartype api_version: str - :ivar is_current: Indicates if API revision is current api revision. - :vartype is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :ivar api_revision_description: Description of the API Revision. - :vartype api_revision_description: str - :ivar api_version_description: Description of the API Version. - :vartype api_version_description: str - :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. - :vartype api_version_set_id: str - :ivar subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :vartype subscription_required: bool - :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of - a URL. - :vartype terms_of_service_url: str - :ivar contact: Contact information for the API. - :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :ivar license: License information for the API. - :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :ivar source_api_id: API identifier of the source API. - :vartype source_api_id: str - :ivar display_name: API name. Must be 1 to 300 characters long. - :vartype display_name: str - :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :vartype service_url: str - :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the - API Management service instance. It is appended to the API endpoint base URL specified during - the service instance creation to form a public URL for this API. - :vartype path: str - :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :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. 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: - ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector - :ivar soap_api_type: Type of API to create. - - - * ``http`` creates a REST API - * ``soap`` creates a SOAP pass-through API - * ``websocket`` creates websocket API - * ``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', - 'query'. Known values are: "template" and "query". - :vartype translate_required_query_parameters_conduct: str or - ~azure.mgmt.apimanagement.models.TranslateRequiredQueryParametersConduct - """ - - _validation = { - "api_revision": {"max_length": 100, "min_length": 1}, - "api_version": {"max_length": 100}, - "is_online": {"readonly": True}, - "api_revision_description": {"max_length": 256}, - "api_version_description": {"max_length": 256}, - "display_name": {"max_length": 300, "min_length": 1}, - "service_url": {"max_length": 2000}, - "path": {"max_length": 400}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "description": {"key": "properties.description", "type": "str"}, - "authentication_settings": { - "key": "properties.authenticationSettings", - "type": "AuthenticationSettingsContract", - }, - "subscription_key_parameter_names": { - "key": "properties.subscriptionKeyParameterNames", - "type": "SubscriptionKeyParameterNamesContract", - }, - "api_type": {"key": "properties.type", "type": "str"}, - "api_revision": {"key": "properties.apiRevision", "type": "str"}, - "api_version": {"key": "properties.apiVersion", "type": "str"}, - "is_current": {"key": "properties.isCurrent", "type": "bool"}, - "is_online": {"key": "properties.isOnline", "type": "bool"}, - "api_revision_description": {"key": "properties.apiRevisionDescription", "type": "str"}, - "api_version_description": {"key": "properties.apiVersionDescription", "type": "str"}, - "api_version_set_id": {"key": "properties.apiVersionSetId", "type": "str"}, - "subscription_required": {"key": "properties.subscriptionRequired", "type": "bool"}, - "terms_of_service_url": {"key": "properties.termsOfServiceUrl", "type": "str"}, - "contact": {"key": "properties.contact", "type": "ApiContactInformation"}, - "license": {"key": "properties.license", "type": "ApiLicenseInformation"}, - "source_api_id": {"key": "properties.sourceApiId", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "service_url": {"key": "properties.serviceUrl", "type": "str"}, - "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"}, - "soap_api_type": {"key": "properties.apiType", "type": "str"}, - "translate_required_query_parameters_conduct": { - "key": "properties.translateRequiredQueryParameters", - "type": "str", - }, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - description: Optional[str] = None, - authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "_models.ApiType"]] = None, - api_revision: Optional[str] = None, - api_version: Optional[str] = None, - is_current: Optional[bool] = None, - api_revision_description: Optional[str] = None, - api_version_description: Optional[str] = None, - api_version_set_id: Optional[str] = None, - subscription_required: Optional[bool] = None, - terms_of_service_url: Optional[str] = None, - contact: Optional["_models.ApiContactInformation"] = None, - license: Optional["_models.ApiLicenseInformation"] = None, - source_api_id: Optional[str] = None, - display_name: Optional[str] = None, - service_url: Optional[str] = None, - path: Optional[str] = None, - protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, - api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, - value: Optional[str] = None, - format: Optional[Union[str, "_models.ContentFormat"]] = None, - wsdl_selector: Optional["_models.ApiCreateOrUpdatePropertiesWsdlSelector"] = None, - soap_api_type: Optional[Union[str, "_models.SoapApiType"]] = None, - translate_required_query_parameters_conduct: Optional[ - Union[str, "_models.TranslateRequiredQueryParametersConduct"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the API. May include HTML formatting tags. - :paramtype description: str - :keyword authentication_settings: Collection of authentication settings included into this API. - :paramtype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :paramtype api_revision: str - :keyword api_version: Indicates the version identifier of the API if the API is versioned. - :paramtype api_version: str - :keyword is_current: Indicates if API revision is current api revision. - :paramtype is_current: bool - :keyword api_revision_description: Description of the API Revision. - :paramtype api_revision_description: str - :keyword api_version_description: Description of the API Version. - :paramtype api_version_description: str - :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. - :paramtype api_version_set_id: str - :keyword subscription_required: Specifies whether an API or Product subscription is required - for accessing the API. - :paramtype subscription_required: bool - :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format - of a URL. - :paramtype terms_of_service_url: str - :keyword contact: Contact information for the API. - :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :keyword license: License information for the API. - :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :keyword source_api_id: API identifier of the source API. - :paramtype source_api_id: str - :keyword display_name: API name. Must be 1 to 300 characters long. - :paramtype display_name: str - :keyword service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :paramtype service_url: str - :keyword path: Relative URL uniquely identifying this API and all of its resource paths within - the API Management service instance. It is appended to the API endpoint base URL specified - during the service instance creation to form a public URL for this API. - :paramtype path: str - :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :keyword api_version_set: Version set details. - :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. 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: - ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector - :keyword soap_api_type: Type of API to create. - - - * ``http`` creates a REST API - * ``soap`` creates a SOAP pass-through API - * ``websocket`` creates websocket API - * ``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', - 'query'. Known values are: "template" and "query". - :paramtype translate_required_query_parameters_conduct: str or - ~azure.mgmt.apimanagement.models.TranslateRequiredQueryParametersConduct - """ - super().__init__(**kwargs) - self.description = description - self.authentication_settings = authentication_settings - self.subscription_key_parameter_names = subscription_key_parameter_names - self.api_type = api_type - self.api_revision = api_revision - self.api_version = api_version - self.is_current = is_current - self.is_online = None - self.api_revision_description = api_revision_description - self.api_version_description = api_version_description - self.api_version_set_id = api_version_set_id - self.subscription_required = subscription_required - self.terms_of_service_url = terms_of_service_url - self.contact = contact - self.license = license - self.source_api_id = source_api_id - self.display_name = display_name - self.service_url = service_url - 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 - self.soap_api_type = soap_api_type - self.translate_required_query_parameters_conduct = translate_required_query_parameters_conduct - - -class ApiCreateOrUpdateProperties(ApiContractProperties): - """API Create or Update 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 description: Description of the API. May include HTML formatting tags. - :vartype description: str - :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :vartype api_revision: str - :ivar api_version: Indicates the version identifier of the API if the API is versioned. - :vartype api_version: str - :ivar is_current: Indicates if API revision is current api revision. - :vartype is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :ivar api_revision_description: Description of the API Revision. - :vartype api_revision_description: str - :ivar api_version_description: Description of the API Version. - :vartype api_version_description: str - :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. - :vartype api_version_set_id: str - :ivar subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :vartype subscription_required: bool - :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of - a URL. - :vartype terms_of_service_url: str - :ivar contact: Contact information for the API. - :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :ivar license: License information for the API. - :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :ivar source_api_id: API identifier of the source API. - :vartype source_api_id: str - :ivar display_name: API name. Must be 1 to 300 characters long. - :vartype display_name: str - :ivar service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :vartype service_url: str - :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the - API Management service instance. It is appended to the API endpoint base URL specified during - the service instance creation to form a public URL for this API. Required. - :vartype path: str - :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :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. 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: - ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector - :ivar soap_api_type: Type of API to create. - - - * ``http`` creates a REST API - * ``soap`` creates a SOAP pass-through API - * ``websocket`` creates websocket API - * ``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', - 'query'. Known values are: "template" and "query". - :vartype translate_required_query_parameters_conduct: str or - ~azure.mgmt.apimanagement.models.TranslateRequiredQueryParametersConduct - """ - - _validation = { - "api_revision": {"max_length": 100, "min_length": 1}, - "api_version": {"max_length": 100}, - "is_online": {"readonly": True}, - "api_revision_description": {"max_length": 256}, - "api_version_description": {"max_length": 256}, - "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 = { - "description": {"key": "description", "type": "str"}, - "authentication_settings": {"key": "authenticationSettings", "type": "AuthenticationSettingsContract"}, - "subscription_key_parameter_names": { - "key": "subscriptionKeyParameterNames", - "type": "SubscriptionKeyParameterNamesContract", - }, - "api_type": {"key": "type", "type": "str"}, - "api_revision": {"key": "apiRevision", "type": "str"}, - "api_version": {"key": "apiVersion", "type": "str"}, - "is_current": {"key": "isCurrent", "type": "bool"}, - "is_online": {"key": "isOnline", "type": "bool"}, - "api_revision_description": {"key": "apiRevisionDescription", "type": "str"}, - "api_version_description": {"key": "apiVersionDescription", "type": "str"}, - "api_version_set_id": {"key": "apiVersionSetId", "type": "str"}, - "subscription_required": {"key": "subscriptionRequired", "type": "bool"}, - "terms_of_service_url": {"key": "termsOfServiceUrl", "type": "str"}, - "contact": {"key": "contact", "type": "ApiContactInformation"}, - "license": {"key": "license", "type": "ApiLicenseInformation"}, - "source_api_id": {"key": "sourceApiId", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "service_url": {"key": "serviceUrl", "type": "str"}, - "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"}, - "soap_api_type": {"key": "apiType", "type": "str"}, - "translate_required_query_parameters_conduct": {"key": "translateRequiredQueryParameters", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - path: str, - description: Optional[str] = None, - authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "_models.ApiType"]] = None, - api_revision: Optional[str] = None, - api_version: Optional[str] = None, - is_current: Optional[bool] = None, - api_revision_description: Optional[str] = None, - api_version_description: Optional[str] = None, - api_version_set_id: Optional[str] = None, - subscription_required: Optional[bool] = None, - terms_of_service_url: Optional[str] = None, - contact: Optional["_models.ApiContactInformation"] = None, - license: Optional["_models.ApiLicenseInformation"] = None, - source_api_id: Optional[str] = None, - display_name: Optional[str] = None, - service_url: Optional[str] = None, - protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, - api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, - value: Optional[str] = None, - format: Optional[Union[str, "_models.ContentFormat"]] = None, - wsdl_selector: Optional["_models.ApiCreateOrUpdatePropertiesWsdlSelector"] = None, - soap_api_type: Optional[Union[str, "_models.SoapApiType"]] = None, - translate_required_query_parameters_conduct: Optional[ - Union[str, "_models.TranslateRequiredQueryParametersConduct"] - ] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the API. May include HTML formatting tags. - :paramtype description: str - :keyword authentication_settings: Collection of authentication settings included into this API. - :paramtype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :paramtype api_revision: str - :keyword api_version: Indicates the version identifier of the API if the API is versioned. - :paramtype api_version: str - :keyword is_current: Indicates if API revision is current api revision. - :paramtype is_current: bool - :keyword api_revision_description: Description of the API Revision. - :paramtype api_revision_description: str - :keyword api_version_description: Description of the API Version. - :paramtype api_version_description: str - :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. - :paramtype api_version_set_id: str - :keyword subscription_required: Specifies whether an API or Product subscription is required - for accessing the API. - :paramtype subscription_required: bool - :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format - of a URL. - :paramtype terms_of_service_url: str - :keyword contact: Contact information for the API. - :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :keyword license: License information for the API. - :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :keyword source_api_id: API identifier of the source API. - :paramtype source_api_id: str - :keyword display_name: API name. Must be 1 to 300 characters long. - :paramtype display_name: str - :keyword service_url: Absolute URL of the backend service implementing this API. Cannot be more - than 2000 characters long. - :paramtype service_url: str - :keyword path: Relative URL uniquely identifying this API and all of its resource paths within - the API Management service instance. It is appended to the API endpoint base URL specified - during the service instance creation to form a public URL for this API. Required. - :paramtype path: str - :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :keyword api_version_set: Version set details. - :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. 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: - ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector - :keyword soap_api_type: Type of API to create. - - - * ``http`` creates a REST API - * ``soap`` creates a SOAP pass-through API - * ``websocket`` creates websocket API - * ``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', - 'query'. Known values are: "template" and "query". - :paramtype translate_required_query_parameters_conduct: str or - ~azure.mgmt.apimanagement.models.TranslateRequiredQueryParametersConduct - """ - super().__init__( - description=description, - authentication_settings=authentication_settings, - subscription_key_parameter_names=subscription_key_parameter_names, - api_type=api_type, - api_revision=api_revision, - api_version=api_version, - is_current=is_current, - api_revision_description=api_revision_description, - api_version_description=api_version_description, - api_version_set_id=api_version_set_id, - subscription_required=subscription_required, - terms_of_service_url=terms_of_service_url, - contact=contact, - license=license, - source_api_id=source_api_id, - display_name=display_name, - service_url=service_url, - path=path, - protocols=protocols, - api_version_set=api_version_set, - **kwargs - ) - self.value = value - self.format = format - self.wsdl_selector = wsdl_selector - self.soap_api_type = soap_api_type - self.translate_required_query_parameters_conduct = translate_required_query_parameters_conduct - - -class ApiCreateOrUpdatePropertiesWsdlSelector(_serialization.Model): - """Criteria to limit import of WSDL to a subset of the document. - - :ivar wsdl_service_name: Name of service to import from WSDL. - :vartype wsdl_service_name: str - :ivar wsdl_endpoint_name: Name of endpoint(port) to import from WSDL. - :vartype wsdl_endpoint_name: str - """ - - _attribute_map = { - "wsdl_service_name": {"key": "wsdlServiceName", "type": "str"}, - "wsdl_endpoint_name": {"key": "wsdlEndpointName", "type": "str"}, - } - - def __init__( - self, *, wsdl_service_name: Optional[str] = None, wsdl_endpoint_name: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword wsdl_service_name: Name of service to import from WSDL. - :paramtype wsdl_service_name: str - :keyword wsdl_endpoint_name: Name of endpoint(port) to import from WSDL. - :paramtype wsdl_endpoint_name: str - """ - super().__init__(**kwargs) - self.wsdl_service_name = wsdl_service_name - self.wsdl_endpoint_name = wsdl_endpoint_name - - -class ApiExportResult(_serialization.Model): - """API Export result. - - :ivar id: ResourceId of the API which was exported. - :vartype id: str - :ivar export_result_format: Format in which the API Details are exported to the Storage Blob - with Sas Key valid for 5 minutes. Known values are: "swagger-link-json", "wsdl-link+xml", - "wadl-link-json", and "openapi-link". - :vartype export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat - :ivar value: The object defining the schema of the exported API Detail. - :vartype value: ~azure.mgmt.apimanagement.models.ApiExportResultValue - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "export_result_format": {"key": "format", "type": "str"}, - "value": {"key": "value", "type": "ApiExportResultValue"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - export_result_format: Optional[Union[str, "_models.ExportResultFormat"]] = None, - value: Optional["_models.ApiExportResultValue"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: ResourceId of the API which was exported. - :paramtype id: str - :keyword export_result_format: Format in which the API Details are exported to the Storage Blob - with Sas Key valid for 5 minutes. Known values are: "swagger-link-json", "wsdl-link+xml", - "wadl-link-json", and "openapi-link". - :paramtype export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat - :keyword value: The object defining the schema of the exported API Detail. - :paramtype value: ~azure.mgmt.apimanagement.models.ApiExportResultValue - """ - super().__init__(**kwargs) - self.id = id - self.export_result_format = export_result_format - self.value = value - - -class ApiExportResultValue(_serialization.Model): - """The object defining the schema of the exported API Detail. - - :ivar link: Link to the Storage Blob containing the result of the export operation. The Blob - Uri is only valid for 5 minutes. - :vartype link: str - """ - - _attribute_map = { - "link": {"key": "link", "type": "str"}, - } - - def __init__(self, *, link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword link: Link to the Storage Blob containing the result of the export operation. The Blob - Uri is only valid for 5 minutes. - :paramtype link: str - """ - super().__init__(**kwargs) - self.link = link - - -class ApiLicenseInformation(_serialization.Model): - """API license information. - - :ivar name: The license name used for the API. - :vartype name: str - :ivar url: A URL to the license used for the API. MUST be in the format of a URL. - :vartype url: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "url": {"key": "url", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, url: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: The license name used for the API. - :paramtype name: str - :keyword url: A URL to the license used for the API. MUST be in the format of a URL. - :paramtype url: str - """ - super().__init__(**kwargs) - self.name = name - self.url = url - - -class ApiManagementGatewayBaseProperties(_serialization.Model): - """Base 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 - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "target_provisioning_state": {"readonly": True}, - "created_at_utc": {"readonly": True}, - } - - _attribute_map = { - "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, - *, - 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 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.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 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 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 = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ApiManagementGatewayConfigConnectionResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: List["_models.ApiManagementGatewayConfigConnectionResource"], - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Result of the List API Management gateway config connection operation. - Required. - :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.value = value - self.next_link = next_link - - -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 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. - :vartype provisioning_state: str - :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): - """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.ApiGatewaySkuType - :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.ApiGatewaySkuType"], 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.ApiGatewaySkuType - :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.ApiGatewaySkuType - :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.ApiGatewaySkuType"]] = 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.ApiGatewaySkuType - :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): - """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): - """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 - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.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 gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :vartype public_ip_address_id: str - :ivar public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :ivar custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :vartype custom_properties: dict[str, str] - :ivar certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :vartype enable_client_certificate: bool - :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT - Gateway deployed service. Available only for Premium SKU on stv2 platform. - :vartype outbound_public_ip_addresses: list[str] - :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :vartype disable_gateway: bool - :ivar virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :ivar api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag - is specified and set to True all other properties will be ignored. - :vartype restore: bool - :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. - :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", "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 = { - "notification_sender_email": {"max_length": 100}, - "provisioning_state": {"readonly": True}, - "target_provisioning_state": {"readonly": True}, - "created_at_utc": {"readonly": True}, - "gateway_url": {"readonly": True}, - "gateway_regional_url": {"readonly": True}, - "portal_url": {"readonly": True}, - "management_api_url": {"readonly": True}, - "scm_url": {"readonly": True}, - "developer_portal_url": {"readonly": True}, - "public_ip_addresses": {"readonly": True}, - "private_ip_addresses": {"readonly": True}, - "outbound_public_ip_addresses": {"readonly": True}, - "platform_version": {"readonly": True}, - } - - _attribute_map = { - "notification_sender_email": {"key": "notificationSenderEmail", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "target_provisioning_state": {"key": "targetProvisioningState", "type": "str"}, - "created_at_utc": {"key": "createdAtUtc", "type": "iso-8601"}, - "gateway_url": {"key": "gatewayUrl", "type": "str"}, - "gateway_regional_url": {"key": "gatewayRegionalUrl", "type": "str"}, - "portal_url": {"key": "portalUrl", "type": "str"}, - "management_api_url": {"key": "managementApiUrl", "type": "str"}, - "scm_url": {"key": "scmUrl", "type": "str"}, - "developer_portal_url": {"key": "developerPortalUrl", "type": "str"}, - "hostname_configurations": {"key": "hostnameConfigurations", "type": "[HostnameConfiguration]"}, - "public_ip_addresses": {"key": "publicIPAddresses", "type": "[str]"}, - "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}"}, - "certificates": {"key": "certificates", "type": "[CertificateConfiguration]"}, - "enable_client_certificate": {"key": "enableClientCertificate", "type": "bool"}, - "nat_gateway_state": {"key": "natGatewayState", "type": "str"}, - "outbound_public_ip_addresses": {"key": "outboundPublicIPAddresses", "type": "[str]"}, - "disable_gateway": {"key": "disableGateway", "type": "bool"}, - "virtual_network_type": {"key": "virtualNetworkType", "type": "str"}, - "api_version_constraint": {"key": "apiVersionConstraint", "type": "ApiVersionConstraint"}, - "restore": {"key": "restore", "type": "bool"}, - "private_endpoint_connections": { - "key": "privateEndpointConnections", - "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 - self, - *, - notification_sender_email: Optional[str] = None, - 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, - certificates: Optional[List["_models.CertificateConfiguration"]] = None, - enable_client_certificate: bool = False, - nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, - disable_gateway: bool = False, - 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: - """ - :keyword notification_sender_email: Email address from which the notification will be sent. - :paramtype notification_sender_email: str - :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: - list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :paramtype public_ip_address_id: str - :keyword public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :keyword custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :paramtype custom_properties: dict[str, str] - :keyword certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :paramtype enable_client_certificate: bool - :keyword nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :paramtype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :keyword disable_gateway: Property only valid for an Api Management service deployed in - multiple locations. This can be used to disable the gateway in master region. - :paramtype disable_gateway: bool - :keyword virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :keyword api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this - flag is specified and set to True all other properties will be ignored. - :paramtype restore: bool - :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 - self.provisioning_state = None - self.target_provisioning_state = None - self.created_at_utc = None - self.gateway_url = None - self.gateway_regional_url = None - self.portal_url = None - self.management_api_url = None - self.scm_url = None - self.developer_portal_url = None - self.hostname_configurations = hostname_configurations - self.public_ip_addresses = None - 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 - self.certificates = certificates - self.enable_client_certificate = enable_client_certificate - self.nat_gateway_state = nat_gateway_state - self.outbound_public_ip_addresses = None - self.disable_gateway = disable_gateway - self.virtual_network_type = virtual_network_type - self.api_version_constraint = api_version_constraint - 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 - """Parameters supplied to the CheckNameAvailability operation. - - All required parameters must be populated in order to send to server. - - :ivar name: The name to check for availability. Required. - :vartype name: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: str, **kwargs: Any) -> None: - """ - :keyword name: The name to check for availability. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - - -class ApiManagementServiceGetDomainOwnershipIdentifierResult(_serialization.Model): # pylint: disable=name-too-long - """Response of the GetDomainOwnershipIdentifier operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar domain_ownership_identifier: The domain ownership identifier value. - :vartype domain_ownership_identifier: str - """ - - _validation = { - "domain_ownership_identifier": {"readonly": True}, - } - - _attribute_map = { - "domain_ownership_identifier": {"key": "domainOwnershipIdentifier", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.domain_ownership_identifier = None - - -class ApiManagementServiceGetSsoTokenResult(_serialization.Model): - """The response of the GetSsoToken operation. - - :ivar redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. - :vartype redirect_uri: str - """ - - _attribute_map = { - "redirect_uri": {"key": "redirectUri", "type": "str"}, - } - - def __init__(self, *, redirect_uri: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. - :paramtype redirect_uri: str - """ - super().__init__(**kwargs) - self.redirect_uri = redirect_uri - - -class ApiManagementServiceIdentity(_serialization.Model): - """Identity properties of the Api Management service resource. - - 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 type: The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' - includes both an implicitly created identity and a set of user assigned identities. The type - 'None' will remove any identities from the service. Required. Known values are: - "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :vartype type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType - :ivar principal_id: The principal id of the identity. - :vartype principal_id: str - :ivar tenant_id: The client tenant id of the identity. - :vartype tenant_id: str - :ivar user_assigned_identities: The list of user identities associated with the resource. The - user identity - dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ - providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :vartype user_assigned_identities: dict[str, - ~azure.mgmt.apimanagement.models.UserIdentityProperties] - """ - - _validation = { - "type": {"required": True}, - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.ApimIdentityType"], - user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of identity used for the resource. The type 'SystemAssigned, - UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the service. Required. Known values - are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType - :keyword user_assigned_identities: The list of user identities associated with the resource. - The user identity - dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ - providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :paramtype user_assigned_identities: dict[str, - ~azure.mgmt.apimanagement.models.UserIdentityProperties] - """ - super().__init__(**kwargs) - self.type = type - self.principal_id = None - self.tenant_id = None - self.user_assigned_identities = user_assigned_identities - - -class ApiManagementServiceListResult(_serialization.Model): - """The response of the List API Management services operation. - - All required parameters must be populated in order to send to server. - - :ivar value: Result of the List API Management services operation. Required. - :vartype value: list[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :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": "[ApiManagementServiceResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.ApiManagementServiceResource"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: Result of the List API Management services operation. Required. - :paramtype value: list[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :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 ApiManagementServiceNameAvailabilityResult(_serialization.Model): # pylint: disable=name-too-long - """Response of the CheckNameAvailability operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name_available: True if the name is available and can be used to create a new API - Management service; otherwise false. - :vartype name_available: bool - :ivar message: If reason == invalid, provide the user with the reason why the given name is - invalid, and provide the resource naming requirements so that the user can select a valid name. - If reason == AlreadyExists, explain that :code:`` is already in use, and direct - them to select a different name. - :vartype message: str - :ivar reason: 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 already in use and is therefore unavailable. Known values are: "Valid", "Invalid", and - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason - """ - - _validation = { - "name_available": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "name_available": {"key": "nameAvailable", "type": "bool"}, - "message": {"key": "message", "type": "str"}, - "reason": {"key": "reason", "type": "str"}, - } - - def __init__(self, *, reason: Optional[Union[str, "_models.NameAvailabilityReason"]] = None, **kwargs: Any) -> None: - """ - :keyword reason: 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 already in use and is therefore unavailable. Known values are: "Valid", - "Invalid", and "AlreadyExists". - :paramtype reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason - """ - super().__init__(**kwargs) - self.name_available = None - self.message = None - self.reason = reason - - -class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): - """Properties of an API Management service resource description. - - 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 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 - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.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 gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :vartype public_ip_address_id: str - :ivar public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :ivar custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :vartype custom_properties: dict[str, str] - :ivar certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :vartype enable_client_certificate: bool - :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT - Gateway deployed service. Available only for Premium SKU on stv2 platform. - :vartype outbound_public_ip_addresses: list[str] - :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :vartype disable_gateway: bool - :ivar virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :ivar api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag - is specified and set to True all other properties will be ignored. - :vartype restore: bool - :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. - :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", "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. - :vartype publisher_name: str - """ - - _validation = { - "notification_sender_email": {"max_length": 100}, - "provisioning_state": {"readonly": True}, - "target_provisioning_state": {"readonly": True}, - "created_at_utc": {"readonly": True}, - "gateway_url": {"readonly": True}, - "gateway_regional_url": {"readonly": True}, - "portal_url": {"readonly": True}, - "management_api_url": {"readonly": True}, - "scm_url": {"readonly": True}, - "developer_portal_url": {"readonly": True}, - "public_ip_addresses": {"readonly": True}, - "private_ip_addresses": {"readonly": True}, - "outbound_public_ip_addresses": {"readonly": True}, - "platform_version": {"readonly": True}, - "publisher_email": {"required": True, "max_length": 100}, - "publisher_name": {"required": True, "max_length": 100}, - } - - _attribute_map = { - "notification_sender_email": {"key": "notificationSenderEmail", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "target_provisioning_state": {"key": "targetProvisioningState", "type": "str"}, - "created_at_utc": {"key": "createdAtUtc", "type": "iso-8601"}, - "gateway_url": {"key": "gatewayUrl", "type": "str"}, - "gateway_regional_url": {"key": "gatewayRegionalUrl", "type": "str"}, - "portal_url": {"key": "portalUrl", "type": "str"}, - "management_api_url": {"key": "managementApiUrl", "type": "str"}, - "scm_url": {"key": "scmUrl", "type": "str"}, - "developer_portal_url": {"key": "developerPortalUrl", "type": "str"}, - "hostname_configurations": {"key": "hostnameConfigurations", "type": "[HostnameConfiguration]"}, - "public_ip_addresses": {"key": "publicIPAddresses", "type": "[str]"}, - "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}"}, - "certificates": {"key": "certificates", "type": "[CertificateConfiguration]"}, - "enable_client_certificate": {"key": "enableClientCertificate", "type": "bool"}, - "nat_gateway_state": {"key": "natGatewayState", "type": "str"}, - "outbound_public_ip_addresses": {"key": "outboundPublicIPAddresses", "type": "[str]"}, - "disable_gateway": {"key": "disableGateway", "type": "bool"}, - "virtual_network_type": {"key": "virtualNetworkType", "type": "str"}, - "api_version_constraint": {"key": "apiVersionConstraint", "type": "ApiVersionConstraint"}, - "restore": {"key": "restore", "type": "bool"}, - "private_endpoint_connections": { - "key": "privateEndpointConnections", - "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"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - publisher_email: str, - publisher_name: str, - notification_sender_email: Optional[str] = None, - 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, - certificates: Optional[List["_models.CertificateConfiguration"]] = None, - enable_client_certificate: bool = False, - nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, - disable_gateway: bool = False, - 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: - """ - :keyword notification_sender_email: Email address from which the notification will be sent. - :paramtype notification_sender_email: str - :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: - list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :paramtype public_ip_address_id: str - :keyword public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :keyword custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :paramtype custom_properties: dict[str, str] - :keyword certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :paramtype enable_client_certificate: bool - :keyword nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :paramtype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :keyword disable_gateway: Property only valid for an Api Management service deployed in - multiple locations. This can be used to disable the gateway in master region. - :paramtype disable_gateway: bool - :keyword virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :keyword api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this - flag is specified and set to True all other properties will be ignored. - :paramtype restore: bool - :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. - :paramtype publisher_name: str - """ - super().__init__( - notification_sender_email=notification_sender_email, - 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, - certificates=certificates, - enable_client_certificate=enable_client_certificate, - nat_gateway_state=nat_gateway_state, - disable_gateway=disable_gateway, - virtual_network_type=virtual_network_type, - 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 ApiManagementServiceResource(ApimResource): - """A single API Management service 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 service. Required. - :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :ivar identity: Managed service identity of the Api Management service. - :vartype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity - :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 zones: A list of availability zones denoting where the resource needs to come from. - :vartype zones: list[str] - :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 - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.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 gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :vartype public_ip_address_id: str - :ivar public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :ivar custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :vartype custom_properties: dict[str, str] - :ivar certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :vartype enable_client_certificate: bool - :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT - Gateway deployed service. Available only for Premium SKU on stv2 platform. - :vartype outbound_public_ip_addresses: list[str] - :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :vartype disable_gateway: bool - :ivar virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :ivar api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag - is specified and set to True all other properties will be ignored. - :vartype restore: bool - :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. - :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", "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. - :vartype publisher_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "sku": {"required": True}, - "system_data": {"readonly": True}, - "location": {"required": True}, - "etag": {"readonly": True}, - "notification_sender_email": {"max_length": 100}, - "provisioning_state": {"readonly": True}, - "target_provisioning_state": {"readonly": True}, - "created_at_utc": {"readonly": True}, - "gateway_url": {"readonly": True}, - "gateway_regional_url": {"readonly": True}, - "portal_url": {"readonly": True}, - "management_api_url": {"readonly": True}, - "scm_url": {"readonly": True}, - "developer_portal_url": {"readonly": True}, - "public_ip_addresses": {"readonly": True}, - "private_ip_addresses": {"readonly": True}, - "outbound_public_ip_addresses": {"readonly": True}, - "platform_version": {"readonly": True}, - "publisher_email": {"required": True, "max_length": 100}, - "publisher_name": {"required": True, "max_length": 100}, - } - - _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": "ApiManagementServiceSkuProperties"}, - "identity": {"key": "identity", "type": "ApiManagementServiceIdentity"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "location": {"key": "location", "type": "str"}, - "etag": {"key": "etag", "type": "str"}, - "zones": {"key": "zones", "type": "[str]"}, - "notification_sender_email": {"key": "properties.notificationSenderEmail", "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"}, - "gateway_url": {"key": "properties.gatewayUrl", "type": "str"}, - "gateway_regional_url": {"key": "properties.gatewayRegionalUrl", "type": "str"}, - "portal_url": {"key": "properties.portalUrl", "type": "str"}, - "management_api_url": {"key": "properties.managementApiUrl", "type": "str"}, - "scm_url": {"key": "properties.scmUrl", "type": "str"}, - "developer_portal_url": {"key": "properties.developerPortalUrl", "type": "str"}, - "hostname_configurations": {"key": "properties.hostnameConfigurations", "type": "[HostnameConfiguration]"}, - "public_ip_addresses": {"key": "properties.publicIPAddresses", "type": "[str]"}, - "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", - }, - "additional_locations": {"key": "properties.additionalLocations", "type": "[AdditionalLocation]"}, - "custom_properties": {"key": "properties.customProperties", "type": "{str}"}, - "certificates": {"key": "properties.certificates", "type": "[CertificateConfiguration]"}, - "enable_client_certificate": {"key": "properties.enableClientCertificate", "type": "bool"}, - "nat_gateway_state": {"key": "properties.natGatewayState", "type": "str"}, - "outbound_public_ip_addresses": {"key": "properties.outboundPublicIPAddresses", "type": "[str]"}, - "disable_gateway": {"key": "properties.disableGateway", "type": "bool"}, - "virtual_network_type": {"key": "properties.virtualNetworkType", "type": "str"}, - "api_version_constraint": {"key": "properties.apiVersionConstraint", "type": "ApiVersionConstraint"}, - "restore": {"key": "properties.restore", "type": "bool"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "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"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - sku: "_models.ApiManagementServiceSkuProperties", - location: str, - publisher_email: str, - publisher_name: str, - tags: Optional[Dict[str, str]] = None, - identity: Optional["_models.ApiManagementServiceIdentity"] = None, - zones: Optional[List[str]] = None, - notification_sender_email: Optional[str] = None, - 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, - certificates: Optional[List["_models.CertificateConfiguration"]] = None, - enable_client_certificate: bool = False, - nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, - disable_gateway: bool = False, - 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: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: SKU properties of the API Management service. Required. - :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :keyword identity: Managed service identity of the Api Management service. - :paramtype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity - :keyword location: Resource location. Required. - :paramtype location: str - :keyword zones: A list of availability zones denoting where the resource needs to come from. - :paramtype zones: list[str] - :keyword notification_sender_email: Email address from which the notification will be sent. - :paramtype notification_sender_email: str - :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: - list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :paramtype public_ip_address_id: str - :keyword public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :keyword custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :paramtype custom_properties: dict[str, str] - :keyword certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :paramtype enable_client_certificate: bool - :keyword nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :paramtype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :keyword disable_gateway: Property only valid for an Api Management service deployed in - multiple locations. This can be used to disable the gateway in master region. - :paramtype disable_gateway: bool - :keyword virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :keyword api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this - flag is specified and set to True all other properties will be ignored. - :paramtype restore: bool - :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. - :paramtype publisher_name: str - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.identity = identity - self.system_data = None - self.location = location - self.etag = None - self.zones = zones - self.notification_sender_email = notification_sender_email - self.provisioning_state = None - self.target_provisioning_state = None - self.created_at_utc = None - self.gateway_url = None - self.gateway_regional_url = None - self.portal_url = None - self.management_api_url = None - self.scm_url = None - self.developer_portal_url = None - self.hostname_configurations = hostname_configurations - self.public_ip_addresses = None - 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 - self.certificates = certificates - self.enable_client_certificate = enable_client_certificate - self.nat_gateway_state = nat_gateway_state - self.outbound_public_ip_addresses = None - self.disable_gateway = disable_gateway - self.virtual_network_type = virtual_network_type - self.api_version_constraint = api_version_constraint - 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 - - -class ApiManagementServiceSkuProperties(_serialization.Model): - """API Management service 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: "Developer", "Standard", "Premium", - "Basic", "Consumption", "Isolated", "BasicV2", and "StandardV2". - :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. - :vartype capacity: int - """ - - _validation = { - "name": {"required": True}, - "capacity": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "capacity": {"key": "capacity", "type": "int"}, - } - - 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", "Isolated", "BasicV2", and "StandardV2". - :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. - :paramtype capacity: int - """ - super().__init__(**kwargs) - self.name = name - self.capacity = capacity - - -class ApiManagementServiceUpdateParameters(ApimResource): - """Parameter supplied to Update Api Management Service. - - 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 service. - :vartype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :ivar identity: Managed service identity of the Api Management service. - :vartype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity - :ivar etag: ETag of the resource. - :vartype etag: str - :ivar zones: A list of availability zones denoting where the resource needs to come from. - :vartype zones: list[str] - :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 - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.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 gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :vartype public_ip_address_id: str - :ivar public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :ivar custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :vartype custom_properties: dict[str, str] - :ivar certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :vartype enable_client_certificate: bool - :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT - Gateway deployed service. Available only for Premium SKU on stv2 platform. - :vartype outbound_public_ip_addresses: list[str] - :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :vartype disable_gateway: bool - :ivar virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :ivar api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag - is specified and set to True all other properties will be ignored. - :vartype restore: bool - :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. - :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", "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. - :vartype publisher_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "etag": {"readonly": True}, - "notification_sender_email": {"max_length": 100}, - "provisioning_state": {"readonly": True}, - "target_provisioning_state": {"readonly": True}, - "created_at_utc": {"readonly": True}, - "gateway_url": {"readonly": True}, - "gateway_regional_url": {"readonly": True}, - "portal_url": {"readonly": True}, - "management_api_url": {"readonly": True}, - "scm_url": {"readonly": True}, - "developer_portal_url": {"readonly": True}, - "public_ip_addresses": {"readonly": True}, - "private_ip_addresses": {"readonly": True}, - "outbound_public_ip_addresses": {"readonly": True}, - "platform_version": {"readonly": True}, - "publisher_email": {"max_length": 100}, - "publisher_name": {"max_length": 100}, - } - - _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": "ApiManagementServiceSkuProperties"}, - "identity": {"key": "identity", "type": "ApiManagementServiceIdentity"}, - "etag": {"key": "etag", "type": "str"}, - "zones": {"key": "zones", "type": "[str]"}, - "notification_sender_email": {"key": "properties.notificationSenderEmail", "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"}, - "gateway_url": {"key": "properties.gatewayUrl", "type": "str"}, - "gateway_regional_url": {"key": "properties.gatewayRegionalUrl", "type": "str"}, - "portal_url": {"key": "properties.portalUrl", "type": "str"}, - "management_api_url": {"key": "properties.managementApiUrl", "type": "str"}, - "scm_url": {"key": "properties.scmUrl", "type": "str"}, - "developer_portal_url": {"key": "properties.developerPortalUrl", "type": "str"}, - "hostname_configurations": {"key": "properties.hostnameConfigurations", "type": "[HostnameConfiguration]"}, - "public_ip_addresses": {"key": "properties.publicIPAddresses", "type": "[str]"}, - "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", - }, - "additional_locations": {"key": "properties.additionalLocations", "type": "[AdditionalLocation]"}, - "custom_properties": {"key": "properties.customProperties", "type": "{str}"}, - "certificates": {"key": "properties.certificates", "type": "[CertificateConfiguration]"}, - "enable_client_certificate": {"key": "properties.enableClientCertificate", "type": "bool"}, - "nat_gateway_state": {"key": "properties.natGatewayState", "type": "str"}, - "outbound_public_ip_addresses": {"key": "properties.outboundPublicIPAddresses", "type": "[str]"}, - "disable_gateway": {"key": "properties.disableGateway", "type": "bool"}, - "virtual_network_type": {"key": "properties.virtualNetworkType", "type": "str"}, - "api_version_constraint": {"key": "properties.apiVersionConstraint", "type": "ApiVersionConstraint"}, - "restore": {"key": "properties.restore", "type": "bool"}, - "private_endpoint_connections": { - "key": "properties.privateEndpointConnections", - "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"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.ApiManagementServiceSkuProperties"] = None, - identity: Optional["_models.ApiManagementServiceIdentity"] = None, - zones: Optional[List[str]] = None, - notification_sender_email: Optional[str] = None, - 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, - certificates: Optional[List["_models.CertificateConfiguration"]] = None, - enable_client_certificate: bool = False, - nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, - disable_gateway: bool = False, - 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 - ) -> None: - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: SKU properties of the API Management service. - :paramtype sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :keyword identity: Managed service identity of the Api Management service. - :paramtype identity: ~azure.mgmt.apimanagement.models.ApiManagementServiceIdentity - :keyword zones: A list of availability zones denoting where the resource needs to come from. - :paramtype zones: list[str] - :keyword notification_sender_email: Email address from which the notification will be sent. - :paramtype notification_sender_email: str - :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: - list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :paramtype public_ip_address_id: str - :keyword public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :keyword custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :paramtype custom_properties: dict[str, str] - :keyword certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :paramtype enable_client_certificate: bool - :keyword nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :paramtype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :keyword disable_gateway: Property only valid for an Api Management service deployed in - multiple locations. This can be used to disable the gateway in master region. - :paramtype disable_gateway: bool - :keyword virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :keyword api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this - flag is specified and set to True all other properties will be ignored. - :paramtype restore: bool - :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. - :paramtype publisher_name: str - """ - super().__init__(tags=tags, **kwargs) - self.sku = sku - self.identity = identity - self.etag = None - self.zones = zones - self.notification_sender_email = notification_sender_email - self.provisioning_state = None - self.target_provisioning_state = None - self.created_at_utc = None - self.gateway_url = None - self.gateway_regional_url = None - self.portal_url = None - self.management_api_url = None - self.scm_url = None - self.developer_portal_url = None - self.hostname_configurations = hostname_configurations - self.public_ip_addresses = None - 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 - self.certificates = certificates - self.enable_client_certificate = enable_client_certificate - self.nat_gateway_state = nat_gateway_state - self.outbound_public_ip_addresses = None - self.disable_gateway = disable_gateway - self.virtual_network_type = virtual_network_type - self.api_version_constraint = api_version_constraint - 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 - - -class ApiManagementServiceUpdateProperties(ApiManagementServiceBaseProperties): - """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 - :ivar target_provisioning_state: The provisioning state of the API Management service, which is - targeted by the long running operation started on the service. - :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.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 gateway_url: Gateway URL of the API Management service. - :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. - :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management service. - :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API Management service. - :vartype management_api_url: str - :ivar scm_url: SCM endpoint URL of the API Management service. - :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. - :vartype developer_portal_url: str - :ivar hostname_configurations: Custom hostname configuration of the API Management service. - :vartype hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management - service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. - :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management - service in Primary region which is deployed in an Internal Virtual Network. Available only for - Basic, Standard, Premium and Isolated SKU. - :vartype private_ip_addresses: list[str] - :ivar public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :vartype public_ip_address_id: str - :ivar public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :ivar additional_locations: Additional datacenter locations of the API Management service. - :vartype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :ivar custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :vartype custom_properties: dict[str, str] - :ivar certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :vartype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :ivar enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :vartype enable_client_certificate: bool - :ivar nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :vartype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :ivar outbound_public_ip_addresses: Outbound public IPV4 address prefixes associated with NAT - Gateway deployed service. Available only for Premium SKU on stv2 platform. - :vartype outbound_public_ip_addresses: list[str] - :ivar disable_gateway: Property only valid for an Api Management service deployed in multiple - locations. This can be used to disable the gateway in master region. - :vartype disable_gateway: bool - :ivar virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :vartype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :ivar api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :vartype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :ivar restore: Undelete Api Management Service if it was previously soft-deleted. If this flag - is specified and set to True all other properties will be ignored. - :vartype restore: bool - :ivar private_endpoint_connections: List of Private Endpoint Connections of this service. - :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", "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. - :vartype publisher_name: str - """ - - _validation = { - "notification_sender_email": {"max_length": 100}, - "provisioning_state": {"readonly": True}, - "target_provisioning_state": {"readonly": True}, - "created_at_utc": {"readonly": True}, - "gateway_url": {"readonly": True}, - "gateway_regional_url": {"readonly": True}, - "portal_url": {"readonly": True}, - "management_api_url": {"readonly": True}, - "scm_url": {"readonly": True}, - "developer_portal_url": {"readonly": True}, - "public_ip_addresses": {"readonly": True}, - "private_ip_addresses": {"readonly": True}, - "outbound_public_ip_addresses": {"readonly": True}, - "platform_version": {"readonly": True}, - "publisher_email": {"max_length": 100}, - "publisher_name": {"max_length": 100}, - } - - _attribute_map = { - "notification_sender_email": {"key": "notificationSenderEmail", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "target_provisioning_state": {"key": "targetProvisioningState", "type": "str"}, - "created_at_utc": {"key": "createdAtUtc", "type": "iso-8601"}, - "gateway_url": {"key": "gatewayUrl", "type": "str"}, - "gateway_regional_url": {"key": "gatewayRegionalUrl", "type": "str"}, - "portal_url": {"key": "portalUrl", "type": "str"}, - "management_api_url": {"key": "managementApiUrl", "type": "str"}, - "scm_url": {"key": "scmUrl", "type": "str"}, - "developer_portal_url": {"key": "developerPortalUrl", "type": "str"}, - "hostname_configurations": {"key": "hostnameConfigurations", "type": "[HostnameConfiguration]"}, - "public_ip_addresses": {"key": "publicIPAddresses", "type": "[str]"}, - "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}"}, - "certificates": {"key": "certificates", "type": "[CertificateConfiguration]"}, - "enable_client_certificate": {"key": "enableClientCertificate", "type": "bool"}, - "nat_gateway_state": {"key": "natGatewayState", "type": "str"}, - "outbound_public_ip_addresses": {"key": "outboundPublicIPAddresses", "type": "[str]"}, - "disable_gateway": {"key": "disableGateway", "type": "bool"}, - "virtual_network_type": {"key": "virtualNetworkType", "type": "str"}, - "api_version_constraint": {"key": "apiVersionConstraint", "type": "ApiVersionConstraint"}, - "restore": {"key": "restore", "type": "bool"}, - "private_endpoint_connections": { - "key": "privateEndpointConnections", - "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"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - notification_sender_email: Optional[str] = None, - 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, - certificates: Optional[List["_models.CertificateConfiguration"]] = None, - enable_client_certificate: bool = False, - nat_gateway_state: Optional[Union[str, "_models.NatGatewayState"]] = None, - disable_gateway: bool = False, - 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 - ) -> None: - """ - :keyword notification_sender_email: Email address from which the notification will be sent. - :paramtype notification_sender_email: str - :keyword hostname_configurations: Custom hostname configuration of the API Management service. - :paramtype hostname_configurations: - list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :keyword public_ip_address_id: Public Standard SKU IP V4 based IP address to be associated with - Virtual Network deployed service in the region. Supported only for Developer and Premium SKU - being deployed in Virtual Network. - :paramtype public_ip_address_id: str - :keyword public_network_access: 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 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: - ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :keyword additional_locations: Additional datacenter locations of the API Management service. - :paramtype additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :keyword custom_properties: Custom properties of the API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the - cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to - disable just TLS 1.1.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to - disable TLS 1.0 on an API Management service.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used - to disable just TLS 1.1 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used - to disable TLS 1.0 for communications with backends.
Setting - ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable - HTTP2 protocol on an API Management service.
Not specifying any of these properties on - PATCH operation will reset omitted properties' values to their defaults. For all the settings - except Http2 the default value is ``True`` if the service was created on or before April 1, - 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can - disable any of the following ciphers by using settings - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - 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`:\\ - ``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 - :paramtype custom_properties: dict[str, str] - :keyword certificates: List of Certificates that need to be installed in the API Management - service. Max supported certificates that can be installed is 10. - :paramtype certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :keyword enable_client_certificate: Property only meant to be used for Consumption SKU Service. - This enforces a client certificate to be presented on each request to the gateway. This also - enables the ability to authenticate the certificate in the policy on the gateway. - :paramtype enable_client_certificate: bool - :keyword nat_gateway_state: Property can be used to enable NAT Gateway for this API Management - service. Known values are: "Enabled" and "Disabled". - :paramtype nat_gateway_state: str or ~azure.mgmt.apimanagement.models.NatGatewayState - :keyword disable_gateway: Property only valid for an Api Management service deployed in - multiple locations. This can be used to disable the gateway in master region. - :paramtype disable_gateway: bool - :keyword virtual_network_type: 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. Known values are: "None", - "External", and "Internal". - :paramtype virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType - :keyword api_version_constraint: Control Plane Apis version constraint for the API Management - service. - :paramtype api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint - :keyword restore: Undelete Api Management Service if it was previously soft-deleted. If this - flag is specified and set to True all other properties will be ignored. - :paramtype restore: bool - :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. - :paramtype publisher_name: str - """ - super().__init__( - notification_sender_email=notification_sender_email, - 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, - certificates=certificates, - enable_client_certificate=enable_client_certificate, - nat_gateway_state=nat_gateway_state, - disable_gateway=disable_gateway, - virtual_network_type=virtual_network_type, - 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 ApiManagementSku(_serialization.Model): - """Describes an available ApiManagement 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 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:`
` **Basic**. - :vartype tier: str - :ivar size: The Size of the SKU. - :vartype size: str - :ivar family: The Family of this particular SKU. - :vartype family: str - :ivar kind: The Kind of resources that are supported in this SKU. - :vartype kind: str - :ivar capacity: Specifies the number of virtual machines in the scale set. - :vartype capacity: ~azure.mgmt.apimanagement.models.ApiManagementSkuCapacity - :ivar locations: The set of locations that the SKU is available. - :vartype locations: list[str] - :ivar location_info: A list of locations and availability zones in those locations where the - SKU is available. - :vartype location_info: list[~azure.mgmt.apimanagement.models.ApiManagementSkuLocationInfo] - :ivar api_versions: The api versions that support this SKU. - :vartype api_versions: list[str] - :ivar costs: Metadata for retrieving price info. - :vartype costs: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCosts] - :ivar capabilities: A name value pair to describe the capability. - :vartype capabilities: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities] - :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if - there are no restrictions. - :vartype restrictions: list[~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictions] - """ - - _validation = { - "resource_type": {"readonly": True}, - "name": {"readonly": True}, - "tier": {"readonly": True}, - "size": {"readonly": True}, - "family": {"readonly": True}, - "kind": {"readonly": True}, - "capacity": {"readonly": True}, - "locations": {"readonly": True}, - "location_info": {"readonly": True}, - "api_versions": {"readonly": True}, - "costs": {"readonly": True}, - "capabilities": {"readonly": True}, - "restrictions": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - "size": {"key": "size", "type": "str"}, - "family": {"key": "family", "type": "str"}, - "kind": {"key": "kind", "type": "str"}, - "capacity": {"key": "capacity", "type": "ApiManagementSkuCapacity"}, - "locations": {"key": "locations", "type": "[str]"}, - "location_info": {"key": "locationInfo", "type": "[ApiManagementSkuLocationInfo]"}, - "api_versions": {"key": "apiVersions", "type": "[str]"}, - "costs": {"key": "costs", "type": "[ApiManagementSkuCosts]"}, - "capabilities": {"key": "capabilities", "type": "[ApiManagementSkuCapabilities]"}, - "restrictions": {"key": "restrictions", "type": "[ApiManagementSkuRestrictions]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type = None - self.name = None - self.tier = None - self.size = None - self.family = None - self.kind = None - self.capacity = None - self.locations = None - self.location_info = None - self.api_versions = None - self.costs = None - self.capabilities = None - self.restrictions = None - - -class ApiManagementSkuCapabilities(_serialization.Model): - """Describes The SKU capabilities object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: An invariant to describe the feature. - :vartype name: str - :ivar value: An invariant if the feature is measured by quantity. - :vartype value: str - """ - - _validation = { - "name": {"readonly": True}, - "value": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name = None - self.value = None - - -class ApiManagementSkuCapacity(_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.ApiManagementSkuCapacityScaleType - """ - - _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 ApiManagementSkuCosts(_serialization.Model): - """Describes metadata for retrieving price info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar meter_id: Used for querying price from commerce. - :vartype meter_id: str - :ivar quantity: The multiplier is needed to extend the base metered cost. - :vartype quantity: int - :ivar extended_unit: An invariant to show the extended unit. - :vartype extended_unit: str - """ - - _validation = { - "meter_id": {"readonly": True}, - "quantity": {"readonly": True}, - "extended_unit": {"readonly": True}, - } - - _attribute_map = { - "meter_id": {"key": "meterID", "type": "str"}, - "quantity": {"key": "quantity", "type": "int"}, - "extended_unit": {"key": "extendedUnit", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.meter_id = None - self.quantity = None - self.extended_unit = None - - -class ApiManagementSkuLocationInfo(_serialization.Model): - """ApiManagementSkuLocationInfo. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar location: Location of the SKU. - :vartype location: str - :ivar zones: List of availability zones where the SKU is supported. - :vartype zones: list[str] - :ivar zone_details: Details of capabilities available to a SKU in specific zones. - :vartype zone_details: list[~azure.mgmt.apimanagement.models.ApiManagementSkuZoneDetails] - """ - - _validation = { - "location": {"readonly": True}, - "zones": {"readonly": True}, - "zone_details": {"readonly": True}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "zones": {"key": "zones", "type": "[str]"}, - "zone_details": {"key": "zoneDetails", "type": "[ApiManagementSkuZoneDetails]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.location = None - self.zones = None - self.zone_details = None - - -class ApiManagementSkuRestrictionInfo(_serialization.Model): - """ApiManagementSkuRestrictionInfo. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar locations: Locations where the SKU is restricted. - :vartype locations: list[str] - :ivar zones: List of availability zones where the SKU is restricted. - :vartype zones: list[str] - """ - - _validation = { - "locations": {"readonly": True}, - "zones": {"readonly": True}, - } - - _attribute_map = { - "locations": {"key": "locations", "type": "[str]"}, - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.locations = None - self.zones = None - - -class ApiManagementSkuRestrictions(_serialization.Model): - """Describes scaling information of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of restrictions. Known values are: "Location" and "Zone". - :vartype type: str or ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsType - :ivar values: The value of restrictions. If the restriction type is set to location. This would - be different locations where the SKU is restricted. - :vartype values: list[str] - :ivar restriction_info: The information about the restriction where the SKU cannot be used. - :vartype restriction_info: ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Known values are: "QuotaId" and - "NotAvailableForSubscription". - :vartype reason_code: str or - ~azure.mgmt.apimanagement.models.ApiManagementSkuRestrictionsReasonCode - """ - - _validation = { - "type": {"readonly": True}, - "values": {"readonly": True}, - "restriction_info": {"readonly": True}, - "reason_code": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - "restriction_info": {"key": "restrictionInfo", "type": "ApiManagementSkuRestrictionInfo"}, - "reason_code": {"key": "reasonCode", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.values = None - self.restriction_info = None - self.reason_code = None - - -class ApiManagementSkusResult(_serialization.Model): - """The List Resource Skus operation 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 value: The list of skus available for the subscription. Required. - :vartype value: list[~azure.mgmt.apimanagement.models.ApiManagementSku] - :ivar next_link: The URI to fetch the next page of Resource Skus. Call ListNext() with this URI - to fetch the next page of Resource Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ApiManagementSku]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.ApiManagementSku"], **kwargs: Any) -> None: - """ - :keyword value: The list of skus available for the subscription. Required. - :paramtype value: list[~azure.mgmt.apimanagement.models.ApiManagementSku] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class ApiManagementSkuZoneDetails(_serialization.Model): - """Describes The zonal capabilities of a SKU. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The set of zones that the SKU is available in with the specified capabilities. - :vartype name: list[str] - :ivar capabilities: A list of capabilities that are available for the SKU in the specified list - of zones. - :vartype capabilities: list[~azure.mgmt.apimanagement.models.ApiManagementSkuCapabilities] - """ - - _validation = { - "name": {"readonly": True}, - "capabilities": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "[str]"}, - "capabilities": {"key": "capabilities", "type": "[ApiManagementSkuCapabilities]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name = 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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ApiReleaseContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ApiReleaseContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class ApiReleaseContract(ProxyResource): - """ApiRelease 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: Identifier of the API the release belongs to. - :vartype api_id: str - :ivar created_date_time: The time the API was released. The date conforms to the following - format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :vartype created_date_time: ~datetime.datetime - :ivar updated_date_time: The time the API release was updated. - :vartype updated_date_time: ~datetime.datetime - :ivar notes: Release Notes. - :vartype notes: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "created_date_time": {"readonly": True}, - "updated_date_time": {"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"}, - "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, - "updated_date_time": {"key": "properties.updatedDateTime", "type": "iso-8601"}, - "notes": {"key": "properties.notes", "type": "str"}, - } - - def __init__(self, *, api_id: Optional[str] = None, notes: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword api_id: Identifier of the API the release belongs to. - :paramtype api_id: str - :keyword notes: Release Notes. - :paramtype notes: str - """ - super().__init__(**kwargs) - self.api_id = api_id - self.created_date_time = None - self.updated_date_time = None - self.notes = notes - - -class ApiRevisionCollection(_serialization.Model): - """Paged API Revision list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ApiRevisionContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ApiRevisionContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class ApiRevisionContract(_serialization.Model): - """Summary of revision metadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar api_id: Identifier of the API Revision. - :vartype api_id: str - :ivar api_revision: Revision number of API. - :vartype api_revision: str - :ivar created_date_time: The time the API Revision was created. The date conforms to the - following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :vartype created_date_time: ~datetime.datetime - :ivar updated_date_time: The time the API Revision were updated. The date conforms to the - following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :vartype updated_date_time: ~datetime.datetime - :ivar description: Description of the API Revision. - :vartype description: str - :ivar private_url: Gateway URL for accessing the non-current API Revision. - :vartype private_url: str - :ivar is_online: Indicates if API revision is the current api revision. - :vartype is_online: bool - :ivar is_current: Indicates if API revision is accessible via the gateway. - :vartype is_current: bool - """ - - _validation = { - "api_id": {"readonly": True}, - "api_revision": {"readonly": True, "max_length": 100, "min_length": 1}, - "created_date_time": {"readonly": True}, - "updated_date_time": {"readonly": True}, - "description": {"readonly": True, "max_length": 256}, - "private_url": {"readonly": True}, - "is_online": {"readonly": True}, - "is_current": {"readonly": True}, - } - - _attribute_map = { - "api_id": {"key": "apiId", "type": "str"}, - "api_revision": {"key": "apiRevision", "type": "str"}, - "created_date_time": {"key": "createdDateTime", "type": "iso-8601"}, - "updated_date_time": {"key": "updatedDateTime", "type": "iso-8601"}, - "description": {"key": "description", "type": "str"}, - "private_url": {"key": "privateUrl", "type": "str"}, - "is_online": {"key": "isOnline", "type": "bool"}, - "is_current": {"key": "isCurrent", "type": "bool"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.api_id = None - self.api_revision = None - self.created_date_time = None - self.updated_date_time = None - self.description = None - self.private_url = None - self.is_online = None - self.is_current = None - - -class ApiRevisionInfoContract(_serialization.Model): - """Object used to create an API Revision or Version based on an existing API Revision. - - :ivar source_api_id: Resource identifier of API to be used to create the revision from. - :vartype source_api_id: str - :ivar api_version_name: Version identifier for the new API Version. - :vartype api_version_name: str - :ivar api_revision_description: Description of new API Revision. - :vartype api_revision_description: str - :ivar api_version_set: Version set details. - :vartype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails - """ - - _validation = { - "api_version_name": {"max_length": 100}, - "api_revision_description": {"max_length": 256}, - } - - _attribute_map = { - "source_api_id": {"key": "sourceApiId", "type": "str"}, - "api_version_name": {"key": "apiVersionName", "type": "str"}, - "api_revision_description": {"key": "apiRevisionDescription", "type": "str"}, - "api_version_set": {"key": "apiVersionSet", "type": "ApiVersionSetContractDetails"}, - } - - def __init__( - self, - *, - source_api_id: Optional[str] = None, - api_version_name: Optional[str] = None, - api_revision_description: Optional[str] = None, - api_version_set: Optional["_models.ApiVersionSetContractDetails"] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_api_id: Resource identifier of API to be used to create the revision from. - :paramtype source_api_id: str - :keyword api_version_name: Version identifier for the new API Version. - :paramtype api_version_name: str - :keyword api_revision_description: Description of new API Revision. - :paramtype api_revision_description: str - :keyword api_version_set: Version set details. - :paramtype api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails - """ - super().__init__(**kwargs) - self.source_api_id = source_api_id - self.api_version_name = api_version_name - self.api_revision_description = api_revision_description - self.api_version_set = api_version_set - - -class ApiTagResourceContractProperties(ApiEntityBaseContract): - """API contract properties for the Tag Resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the API. May include HTML formatting tags. - :vartype description: str - :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :vartype api_revision: str - :ivar api_version: Indicates the version identifier of the API if the API is versioned. - :vartype api_version: str - :ivar is_current: Indicates if API revision is current api revision. - :vartype is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :ivar api_revision_description: Description of the API Revision. - :vartype api_revision_description: str - :ivar api_version_description: Description of the API Version. - :vartype api_version_description: str - :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. - :vartype api_version_set_id: str - :ivar subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :vartype subscription_required: bool - :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of - a URL. - :vartype terms_of_service_url: str - :ivar contact: Contact information for the API. - :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :ivar license: License information for the API. - :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :ivar id: API identifier in the form /apis/{apiId}. - :vartype id: str - :ivar name: API name. - :vartype name: str - :ivar service_url: Absolute URL of the backend service implementing this API. - :vartype service_url: str - :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the - API Management service instance. It is appended to the API endpoint base URL specified during - the service instance creation to form a public URL for this API. - :vartype path: str - :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - """ - - _validation = { - "api_revision": {"max_length": 100, "min_length": 1}, - "api_version": {"max_length": 100}, - "is_online": {"readonly": True}, - "api_revision_description": {"max_length": 256}, - "api_version_description": {"max_length": 256}, - "name": {"max_length": 300, "min_length": 1}, - "service_url": {"max_length": 2000, "min_length": 1}, - "path": {"max_length": 400}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "authentication_settings": {"key": "authenticationSettings", "type": "AuthenticationSettingsContract"}, - "subscription_key_parameter_names": { - "key": "subscriptionKeyParameterNames", - "type": "SubscriptionKeyParameterNamesContract", - }, - "api_type": {"key": "type", "type": "str"}, - "api_revision": {"key": "apiRevision", "type": "str"}, - "api_version": {"key": "apiVersion", "type": "str"}, - "is_current": {"key": "isCurrent", "type": "bool"}, - "is_online": {"key": "isOnline", "type": "bool"}, - "api_revision_description": {"key": "apiRevisionDescription", "type": "str"}, - "api_version_description": {"key": "apiVersionDescription", "type": "str"}, - "api_version_set_id": {"key": "apiVersionSetId", "type": "str"}, - "subscription_required": {"key": "subscriptionRequired", "type": "bool"}, - "terms_of_service_url": {"key": "termsOfServiceUrl", "type": "str"}, - "contact": {"key": "contact", "type": "ApiContactInformation"}, - "license": {"key": "license", "type": "ApiLicenseInformation"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "service_url": {"key": "serviceUrl", "type": "str"}, - "path": {"key": "path", "type": "str"}, - "protocols": {"key": "protocols", "type": "[str]"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "_models.ApiType"]] = None, - api_revision: Optional[str] = None, - api_version: Optional[str] = None, - is_current: Optional[bool] = None, - api_revision_description: Optional[str] = None, - api_version_description: Optional[str] = None, - api_version_set_id: Optional[str] = None, - subscription_required: Optional[bool] = None, - terms_of_service_url: Optional[str] = None, - contact: Optional["_models.ApiContactInformation"] = None, - license: Optional["_models.ApiLicenseInformation"] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - service_url: Optional[str] = None, - path: Optional[str] = None, - protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the API. May include HTML formatting tags. - :paramtype description: str - :keyword authentication_settings: Collection of authentication settings included into this API. - :paramtype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :paramtype api_revision: str - :keyword api_version: Indicates the version identifier of the API if the API is versioned. - :paramtype api_version: str - :keyword is_current: Indicates if API revision is current api revision. - :paramtype is_current: bool - :keyword api_revision_description: Description of the API Revision. - :paramtype api_revision_description: str - :keyword api_version_description: Description of the API Version. - :paramtype api_version_description: str - :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. - :paramtype api_version_set_id: str - :keyword subscription_required: Specifies whether an API or Product subscription is required - for accessing the API. - :paramtype subscription_required: bool - :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format - of a URL. - :paramtype terms_of_service_url: str - :keyword contact: Contact information for the API. - :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :keyword license: License information for the API. - :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :keyword id: API identifier in the form /apis/{apiId}. - :paramtype id: str - :keyword name: API name. - :paramtype name: str - :keyword service_url: Absolute URL of the backend service implementing this API. - :paramtype service_url: str - :keyword path: Relative URL uniquely identifying this API and all of its resource paths within - the API Management service instance. It is appended to the API endpoint base URL specified - during the service instance creation to form a public URL for this API. - :paramtype path: str - :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - """ - super().__init__( - description=description, - authentication_settings=authentication_settings, - subscription_key_parameter_names=subscription_key_parameter_names, - api_type=api_type, - api_revision=api_revision, - api_version=api_version, - is_current=is_current, - api_revision_description=api_revision_description, - api_version_description=api_version_description, - api_version_set_id=api_version_set_id, - subscription_required=subscription_required, - terms_of_service_url=terms_of_service_url, - contact=contact, - license=license, - **kwargs - ) - self.id = id - self.name = name - self.service_url = service_url - self.path = path - self.protocols = protocols - - -class ApiUpdateContract(_serialization.Model): - """API update contract details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: Description of the API. May include HTML formatting tags. - :vartype description: str - :ivar authentication_settings: Collection of authentication settings included into this API. - :vartype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :vartype api_revision: str - :ivar api_version: Indicates the version identifier of the API if the API is versioned. - :vartype api_version: str - :ivar is_current: Indicates if API revision is current api revision. - :vartype is_current: bool - :ivar is_online: Indicates if API revision is accessible via the gateway. - :vartype is_online: bool - :ivar api_revision_description: Description of the API Revision. - :vartype api_revision_description: str - :ivar api_version_description: Description of the API Version. - :vartype api_version_description: str - :ivar api_version_set_id: A resource identifier for the related ApiVersionSet. - :vartype api_version_set_id: str - :ivar subscription_required: Specifies whether an API or Product subscription is required for - accessing the API. - :vartype subscription_required: bool - :ivar terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format of - a URL. - :vartype terms_of_service_url: str - :ivar contact: Contact information for the API. - :vartype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :ivar license: License information for the API. - :vartype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :ivar display_name: API name. - :vartype display_name: str - :ivar service_url: Absolute URL of the backend service implementing this API. - :vartype service_url: str - :ivar path: Relative URL uniquely identifying this API and all of its resource paths within the - API Management service instance. It is appended to the API endpoint base URL specified during - the service instance creation to form a public URL for this API. - :vartype path: str - :ivar protocols: Describes on which protocols the operations in this API can be invoked. - :vartype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - """ - - _validation = { - "api_revision": {"max_length": 100, "min_length": 1}, - "api_version": {"max_length": 100}, - "is_online": {"readonly": True}, - "api_revision_description": {"max_length": 256}, - "api_version_description": {"max_length": 256}, - "display_name": {"max_length": 300, "min_length": 1}, - "service_url": {"max_length": 2000, "min_length": 1}, - "path": {"max_length": 400}, - } - - _attribute_map = { - "description": {"key": "properties.description", "type": "str"}, - "authentication_settings": { - "key": "properties.authenticationSettings", - "type": "AuthenticationSettingsContract", - }, - "subscription_key_parameter_names": { - "key": "properties.subscriptionKeyParameterNames", - "type": "SubscriptionKeyParameterNamesContract", - }, - "api_type": {"key": "properties.type", "type": "str"}, - "api_revision": {"key": "properties.apiRevision", "type": "str"}, - "api_version": {"key": "properties.apiVersion", "type": "str"}, - "is_current": {"key": "properties.isCurrent", "type": "bool"}, - "is_online": {"key": "properties.isOnline", "type": "bool"}, - "api_revision_description": {"key": "properties.apiRevisionDescription", "type": "str"}, - "api_version_description": {"key": "properties.apiVersionDescription", "type": "str"}, - "api_version_set_id": {"key": "properties.apiVersionSetId", "type": "str"}, - "subscription_required": {"key": "properties.subscriptionRequired", "type": "bool"}, - "terms_of_service_url": {"key": "properties.termsOfServiceUrl", "type": "str"}, - "contact": {"key": "properties.contact", "type": "ApiContactInformation"}, - "license": {"key": "properties.license", "type": "ApiLicenseInformation"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "service_url": {"key": "properties.serviceUrl", "type": "str"}, - "path": {"key": "properties.path", "type": "str"}, - "protocols": {"key": "properties.protocols", "type": "[str]"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - authentication_settings: Optional["_models.AuthenticationSettingsContract"] = None, - subscription_key_parameter_names: Optional["_models.SubscriptionKeyParameterNamesContract"] = None, - api_type: Optional[Union[str, "_models.ApiType"]] = None, - api_revision: Optional[str] = None, - api_version: Optional[str] = None, - is_current: Optional[bool] = None, - api_revision_description: Optional[str] = None, - api_version_description: Optional[str] = None, - api_version_set_id: Optional[str] = None, - subscription_required: Optional[bool] = None, - terms_of_service_url: Optional[str] = None, - contact: Optional["_models.ApiContactInformation"] = None, - license: Optional["_models.ApiLicenseInformation"] = None, - display_name: Optional[str] = None, - service_url: Optional[str] = None, - path: Optional[str] = None, - protocols: Optional[List[Union[str, "_models.Protocol"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the API. May include HTML formatting tags. - :paramtype description: str - :keyword authentication_settings: Collection of authentication settings included into this API. - :paramtype authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :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", "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. - :paramtype api_revision: str - :keyword api_version: Indicates the version identifier of the API if the API is versioned. - :paramtype api_version: str - :keyword is_current: Indicates if API revision is current api revision. - :paramtype is_current: bool - :keyword api_revision_description: Description of the API Revision. - :paramtype api_revision_description: str - :keyword api_version_description: Description of the API Version. - :paramtype api_version_description: str - :keyword api_version_set_id: A resource identifier for the related ApiVersionSet. - :paramtype api_version_set_id: str - :keyword subscription_required: Specifies whether an API or Product subscription is required - for accessing the API. - :paramtype subscription_required: bool - :keyword terms_of_service_url: A URL to the Terms of Service for the API. MUST be in the format - of a URL. - :paramtype terms_of_service_url: str - :keyword contact: Contact information for the API. - :paramtype contact: ~azure.mgmt.apimanagement.models.ApiContactInformation - :keyword license: License information for the API. - :paramtype license: ~azure.mgmt.apimanagement.models.ApiLicenseInformation - :keyword display_name: API name. - :paramtype display_name: str - :keyword service_url: Absolute URL of the backend service implementing this API. - :paramtype service_url: str - :keyword path: Relative URL uniquely identifying this API and all of its resource paths within - the API Management service instance. It is appended to the API endpoint base URL specified - during the service instance creation to form a public URL for this API. - :paramtype path: str - :keyword protocols: Describes on which protocols the operations in this API can be invoked. - :paramtype protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - """ - super().__init__(**kwargs) - self.description = description - self.authentication_settings = authentication_settings - self.subscription_key_parameter_names = subscription_key_parameter_names - self.api_type = api_type - self.api_revision = api_revision - self.api_version = api_version - self.is_current = is_current - self.is_online = None - self.api_revision_description = api_revision_description - self.api_version_description = api_version_description - self.api_version_set_id = api_version_set_id - self.subscription_required = subscription_required - self.terms_of_service_url = terms_of_service_url - self.contact = contact - self.license = license - self.display_name = display_name - self.service_url = service_url - self.path = path - self.protocols = protocols - - -class ApiVersionConstraint(_serialization.Model): - """Control Plane Apis version constraint for the API Management service. - - :ivar min_api_version: Limit control plane API calls to API Management service with version - equal to or newer than this value. - :vartype min_api_version: str - """ - - _attribute_map = { - "min_api_version": {"key": "minApiVersion", "type": "str"}, - } - - def __init__(self, *, min_api_version: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword min_api_version: Limit control plane API calls to API Management service with version - equal to or newer than this value. - :paramtype min_api_version: str - """ - super().__init__(**kwargs) - self.min_api_version = min_api_version - - -class ApiVersionSetCollection(_serialization.Model): - """Paged API Version Set list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] - :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": "[ApiVersionSetContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ApiVersionSetContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] - :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 ApiVersionSetContract(ProxyResource): - """API Version Set 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 description: Description of API Version Set. - :vartype description: str - :ivar version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :vartype version_query_name: str - :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :vartype version_header_name: str - :ivar display_name: Name of API Version Set. - :vartype display_name: str - :ivar versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Known values are: "Segment", "Query", and "Header". - :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "version_query_name": {"max_length": 100, "min_length": 1}, - "version_header_name": {"max_length": 100, "min_length": 1}, - "display_name": {"max_length": 100, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "version_query_name": {"key": "properties.versionQueryName", "type": "str"}, - "version_header_name": {"key": "properties.versionHeaderName", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "versioning_scheme": {"key": "properties.versioningScheme", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - version_query_name: Optional[str] = None, - version_header_name: Optional[str] = None, - display_name: Optional[str] = None, - versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of API Version Set. - :paramtype description: str - :keyword version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :paramtype version_query_name: str - :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :paramtype version_header_name: str - :keyword display_name: Name of API Version Set. - :paramtype display_name: str - :keyword versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Known values are: "Segment", "Query", and "Header". - :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - super().__init__(**kwargs) - self.description = description - self.version_query_name = version_query_name - self.version_header_name = version_header_name - self.display_name = display_name - self.versioning_scheme = versioning_scheme - - -class ApiVersionSetContractDetails(_serialization.Model): - """An API Version Set contains the common configuration for a set of API Versions relating. - - :ivar id: Identifier for existing API Version Set. Omit this value to create a new Version Set. - :vartype id: str - :ivar name: The display Name of the API Version Set. - :vartype name: str - :ivar description: Description of API Version Set. - :vartype description: str - :ivar versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Known values are: "Segment", "Query", and "Header". - :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - :ivar version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :vartype version_query_name: str - :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :vartype version_header_name: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "versioning_scheme": {"key": "versioningScheme", "type": "str"}, - "version_query_name": {"key": "versionQueryName", "type": "str"}, - "version_header_name": {"key": "versionHeaderName", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - description: Optional[str] = None, - versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, - version_query_name: Optional[str] = None, - version_header_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Identifier for existing API Version Set. Omit this value to create a new Version - Set. - :paramtype id: str - :keyword name: The display Name of the API Version Set. - :paramtype name: str - :keyword description: Description of API Version Set. - :paramtype description: str - :keyword versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Known values are: "Segment", "Query", and "Header". - :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - :keyword version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :paramtype version_query_name: str - :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :paramtype version_header_name: str - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.description = description - self.versioning_scheme = versioning_scheme - self.version_query_name = version_query_name - self.version_header_name = version_header_name - - -class ApiVersionSetEntityBase(_serialization.Model): - """API Version set base parameters. - - :ivar description: Description of API Version Set. - :vartype description: str - :ivar version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :vartype version_query_name: str - :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :vartype version_header_name: str - """ - - _validation = { - "version_query_name": {"max_length": 100, "min_length": 1}, - "version_header_name": {"max_length": 100, "min_length": 1}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "version_query_name": {"key": "versionQueryName", "type": "str"}, - "version_header_name": {"key": "versionHeaderName", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - version_query_name: Optional[str] = None, - version_header_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of API Version Set. - :paramtype description: str - :keyword version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :paramtype version_query_name: str - :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :paramtype version_header_name: str - """ - super().__init__(**kwargs) - self.description = description - self.version_query_name = version_query_name - self.version_header_name = version_header_name - - -class ApiVersionSetContractProperties(ApiVersionSetEntityBase): - """Properties of an API Version Set. - - All required parameters must be populated in order to send to server. - - :ivar description: Description of API Version Set. - :vartype description: str - :ivar version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :vartype version_query_name: str - :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :vartype version_header_name: str - :ivar display_name: Name of API Version Set. Required. - :vartype display_name: str - :ivar versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Required. Known values are: "Segment", "Query", and "Header". - :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - - _validation = { - "version_query_name": {"max_length": 100, "min_length": 1}, - "version_header_name": {"max_length": 100, "min_length": 1}, - "display_name": {"required": True, "max_length": 100, "min_length": 1}, - "versioning_scheme": {"required": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "version_query_name": {"key": "versionQueryName", "type": "str"}, - "version_header_name": {"key": "versionHeaderName", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "versioning_scheme": {"key": "versioningScheme", "type": "str"}, - } - - def __init__( - self, - *, - display_name: str, - versioning_scheme: Union[str, "_models.VersioningScheme"], - description: Optional[str] = None, - version_query_name: Optional[str] = None, - version_header_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of API Version Set. - :paramtype description: str - :keyword version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :paramtype version_query_name: str - :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :paramtype version_header_name: str - :keyword display_name: Name of API Version Set. Required. - :paramtype display_name: str - :keyword versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Required. Known values are: "Segment", "Query", and "Header". - :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - super().__init__( - description=description, - version_query_name=version_query_name, - version_header_name=version_header_name, - **kwargs - ) - self.display_name = display_name - self.versioning_scheme = versioning_scheme - - -class ApiVersionSetUpdateParameters(_serialization.Model): - """Parameters to update or create an API Version Set Contract. - - :ivar description: Description of API Version Set. - :vartype description: str - :ivar version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :vartype version_query_name: str - :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :vartype version_header_name: str - :ivar display_name: Name of API Version Set. - :vartype display_name: str - :ivar versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Known values are: "Segment", "Query", and "Header". - :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - - _validation = { - "version_query_name": {"max_length": 100, "min_length": 1}, - "version_header_name": {"max_length": 100, "min_length": 1}, - "display_name": {"max_length": 100, "min_length": 1}, - } - - _attribute_map = { - "description": {"key": "properties.description", "type": "str"}, - "version_query_name": {"key": "properties.versionQueryName", "type": "str"}, - "version_header_name": {"key": "properties.versionHeaderName", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "versioning_scheme": {"key": "properties.versioningScheme", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - version_query_name: Optional[str] = None, - version_header_name: Optional[str] = None, - display_name: Optional[str] = None, - versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of API Version Set. - :paramtype description: str - :keyword version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :paramtype version_query_name: str - :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :paramtype version_header_name: str - :keyword display_name: Name of API Version Set. - :paramtype display_name: str - :keyword versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Known values are: "Segment", "Query", and "Header". - :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - super().__init__(**kwargs) - self.description = description - self.version_query_name = version_query_name - self.version_header_name = version_header_name - self.display_name = display_name - self.versioning_scheme = versioning_scheme - - -class ApiVersionSetUpdateParametersProperties(ApiVersionSetEntityBase): - """Properties used to create or update an API Version Set. - - :ivar description: Description of API Version Set. - :vartype description: str - :ivar version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :vartype version_query_name: str - :ivar version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :vartype version_header_name: str - :ivar display_name: Name of API Version Set. - :vartype display_name: str - :ivar versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Known values are: "Segment", "Query", and "Header". - :vartype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - - _validation = { - "version_query_name": {"max_length": 100, "min_length": 1}, - "version_header_name": {"max_length": 100, "min_length": 1}, - "display_name": {"max_length": 100, "min_length": 1}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "version_query_name": {"key": "versionQueryName", "type": "str"}, - "version_header_name": {"key": "versionHeaderName", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "versioning_scheme": {"key": "versioningScheme", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - version_query_name: Optional[str] = None, - version_header_name: Optional[str] = None, - display_name: Optional[str] = None, - versioning_scheme: Optional[Union[str, "_models.VersioningScheme"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of API Version Set. - :paramtype description: str - :keyword version_query_name: Name of query parameter that indicates the API Version if - versioningScheme is set to ``query``. - :paramtype version_query_name: str - :keyword version_header_name: Name of HTTP header parameter that indicates the API Version if - versioningScheme is set to ``header``. - :paramtype version_header_name: str - :keyword display_name: Name of API Version Set. - :paramtype display_name: str - :keyword versioning_scheme: An value that determines where the API Version identifier will be - located in a HTTP request. Known values are: "Segment", "Query", and "Header". - :paramtype versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme - """ - super().__init__( - description=description, - version_query_name=version_query_name, - version_header_name=version_header_name, - **kwargs - ) - self.display_name = display_name - self.versioning_scheme = versioning_scheme - - -class ArmIdWrapper(_serialization.Model): - """A wrapper for an ARM resource id. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - - -class AssociationContract(ProxyResource): - """Association entity 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 provisioning_state: Provisioning state. Default value is "created". - :vartype provisioning_state: 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"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__(self, *, provisioning_state: Optional[Literal["created"]] = None, **kwargs: Any) -> None: - """ - :keyword provisioning_state: Provisioning state. Default value is "created". - :paramtype provisioning_state: str - """ - super().__init__(**kwargs) - self.provisioning_state = provisioning_state - - -class AuthenticationSettingsContract(_serialization.Model): - """API Authentication Settings. - - :ivar o_auth2: OAuth2 Authentication settings. - :vartype o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract - :ivar openid: OpenID Connect Authentication Settings. - :vartype openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract - :ivar o_auth2_authentication_settings: Collection of OAuth2 authentication settings included - into this API. - :vartype o_auth2_authentication_settings: - list[~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract] - :ivar openid_authentication_settings: Collection of Open ID Connect authentication settings - included into this API. - :vartype openid_authentication_settings: - list[~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract] - """ - - _attribute_map = { - "o_auth2": {"key": "oAuth2", "type": "OAuth2AuthenticationSettingsContract"}, - "openid": {"key": "openid", "type": "OpenIdAuthenticationSettingsContract"}, - "o_auth2_authentication_settings": { - "key": "oAuth2AuthenticationSettings", - "type": "[OAuth2AuthenticationSettingsContract]", - }, - "openid_authentication_settings": { - "key": "openidAuthenticationSettings", - "type": "[OpenIdAuthenticationSettingsContract]", - }, - } - - def __init__( - self, - *, - o_auth2: Optional["_models.OAuth2AuthenticationSettingsContract"] = None, - openid: Optional["_models.OpenIdAuthenticationSettingsContract"] = None, - o_auth2_authentication_settings: Optional[List["_models.OAuth2AuthenticationSettingsContract"]] = None, - openid_authentication_settings: Optional[List["_models.OpenIdAuthenticationSettingsContract"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword o_auth2: OAuth2 Authentication settings. - :paramtype o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract - :keyword openid: OpenID Connect Authentication Settings. - :paramtype openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract - :keyword o_auth2_authentication_settings: Collection of OAuth2 authentication settings included - into this API. - :paramtype o_auth2_authentication_settings: - list[~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract] - :keyword openid_authentication_settings: Collection of Open ID Connect authentication settings - included into this API. - :paramtype openid_authentication_settings: - list[~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract] - """ - super().__init__(**kwargs) - self.o_auth2 = o_auth2 - self.openid = openid - self.o_auth2_authentication_settings = o_auth2_authentication_settings - self.openid_authentication_settings = openid_authentication_settings - - -class AuthorizationAccessPolicyCollection(_serialization.Model): - """Paged Authorization Access Policy list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract] - :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": "[AuthorizationAccessPolicyContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AuthorizationAccessPolicyContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract] - :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 AuthorizationAccessPolicyContract(ProxyResource): - """Authorization access policy contract. - - 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 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. - :vartype object_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"}, - "app_ids": {"key": "properties.appIds", "type": "[str]"}, - "tenant_id": {"key": "properties.tenantId", "type": "str"}, - "object_id": {"key": "properties.objectId", "type": "str"}, - } - - 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 - - -class AuthorizationCollection(_serialization.Model): - """Paged Authorization list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationContract] - :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": "[AuthorizationContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AuthorizationContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationContract] - :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 AuthorizationConfirmConsentCodeRequestContract(_serialization.Model): # pylint: disable=name-too-long - """Authorization confirm consent code request contract. - - :ivar consent_code: The consent code from the authorization server after authorizing and - consenting. - :vartype consent_code: str - """ - - _attribute_map = { - "consent_code": {"key": "consentCode", "type": "str"}, - } - - def __init__(self, *, consent_code: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword consent_code: The consent code from the authorization server after authorizing and - consenting. - :paramtype consent_code: str - """ - super().__init__(**kwargs) - self.consent_code = consent_code - - -class AuthorizationContract(ProxyResource): - """Authorization contract. - - 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 authorization_type: Authorization type options. "OAuth2" - :vartype authorization_type: str or ~azure.mgmt.apimanagement.models.AuthorizationType - :ivar o_auth2_grant_type: OAuth2 grant type options. Known values are: "AuthorizationCode" and - "ClientCredentials". - :vartype o_auth2_grant_type: str or ~azure.mgmt.apimanagement.models.OAuth2GrantType - :ivar parameters: Authorization parameters. - :vartype parameters: dict[str, str] - :ivar error: Authorization error details. - :vartype error: ~azure.mgmt.apimanagement.models.AuthorizationError - :ivar status: Status of the Authorization. - :vartype status: 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"}, - "authorization_type": {"key": "properties.authorizationType", "type": "str"}, - "o_auth2_grant_type": {"key": "properties.oauth2grantType", "type": "str"}, - "parameters": {"key": "properties.parameters", "type": "{str}"}, - "error": {"key": "properties.error", "type": "AuthorizationError"}, - "status": {"key": "properties.status", "type": "str"}, - } - - def __init__( - self, - *, - authorization_type: Optional[Union[str, "_models.AuthorizationType"]] = None, - o_auth2_grant_type: Optional[Union[str, "_models.OAuth2GrantType"]] = None, - parameters: Optional[Dict[str, str]] = None, - error: Optional["_models.AuthorizationError"] = None, - status: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword authorization_type: Authorization type options. "OAuth2" - :paramtype authorization_type: str or ~azure.mgmt.apimanagement.models.AuthorizationType - :keyword o_auth2_grant_type: OAuth2 grant type options. Known values are: "AuthorizationCode" - and "ClientCredentials". - :paramtype o_auth2_grant_type: str or ~azure.mgmt.apimanagement.models.OAuth2GrantType - :keyword parameters: Authorization parameters. - :paramtype parameters: dict[str, str] - :keyword error: Authorization error details. - :paramtype error: ~azure.mgmt.apimanagement.models.AuthorizationError - :keyword status: Status of the Authorization. - :paramtype status: str - """ - super().__init__(**kwargs) - self.authorization_type = authorization_type - self.o_auth2_grant_type = o_auth2_grant_type - self.parameters = parameters - self.error = error - self.status = status - - -class AuthorizationError(_serialization.Model): - """Authorization error details. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message. - :vartype message: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message. - :paramtype message: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - - -class AuthorizationLoginRequestContract(_serialization.Model): - """Authorization login request contract. - - :ivar post_login_redirect_url: The redirect URL after login has completed. - :vartype post_login_redirect_url: str - """ - - _attribute_map = { - "post_login_redirect_url": {"key": "postLoginRedirectUrl", "type": "str"}, - } - - def __init__(self, *, post_login_redirect_url: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword post_login_redirect_url: The redirect URL after login has completed. - :paramtype post_login_redirect_url: str - """ - super().__init__(**kwargs) - self.post_login_redirect_url = post_login_redirect_url - - -class AuthorizationLoginResponseContract(_serialization.Model): - """Authorization login response contract. - - :ivar login_link: The login link. - :vartype login_link: str - """ - - _attribute_map = { - "login_link": {"key": "loginLink", "type": "str"}, - } - - def __init__(self, *, login_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword login_link: The login link. - :paramtype login_link: str - """ - super().__init__(**kwargs) - self.login_link = login_link - - -class AuthorizationProviderCollection(_serialization.Model): - """Paged Authorization Provider list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationProviderContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[AuthorizationProviderContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AuthorizationProviderContract"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationProviderContract] - :keyword next_link: Next page link if any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class AuthorizationProviderContract(ProxyResource): - """Authorization Provider contract. - - 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: Authorization Provider name. Must be 1 to 300 characters long. - :vartype display_name: str - :ivar identity_provider: Identity provider name. Must be 1 to 300 characters long. - :vartype identity_provider: str - :ivar oauth2: OAuth2 settings. - :vartype oauth2: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2Settings - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"max_length": 300, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "identity_provider": {"key": "properties.identityProvider", "type": "str"}, - "oauth2": {"key": "properties.oauth2", "type": "AuthorizationProviderOAuth2Settings"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - identity_provider: Optional[str] = None, - oauth2: Optional["_models.AuthorizationProviderOAuth2Settings"] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: Authorization Provider name. Must be 1 to 300 characters long. - :paramtype display_name: str - :keyword identity_provider: Identity provider name. Must be 1 to 300 characters long. - :paramtype identity_provider: str - :keyword oauth2: OAuth2 settings. - :paramtype oauth2: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2Settings - """ - super().__init__(**kwargs) - self.display_name = display_name - self.identity_provider = identity_provider - self.oauth2 = oauth2 - - -class AuthorizationProviderOAuth2GrantTypes(_serialization.Model): - """Authorization Provider oauth2 grant types settings. - - :ivar authorization_code: OAuth2 authorization code grant parameters. - :vartype authorization_code: dict[str, str] - :ivar client_credentials: OAuth2 client credential grant parameters. - :vartype client_credentials: dict[str, str] - """ - - _attribute_map = { - "authorization_code": {"key": "authorizationCode", "type": "{str}"}, - "client_credentials": {"key": "clientCredentials", "type": "{str}"}, - } - - def __init__( - self, - *, - authorization_code: Optional[Dict[str, str]] = None, - client_credentials: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword authorization_code: OAuth2 authorization code grant parameters. - :paramtype authorization_code: dict[str, str] - :keyword client_credentials: OAuth2 client credential grant parameters. - :paramtype client_credentials: dict[str, str] - """ - super().__init__(**kwargs) - self.authorization_code = authorization_code - self.client_credentials = client_credentials - - -class AuthorizationProviderOAuth2Settings(_serialization.Model): - """OAuth2 settings details. - - :ivar redirect_url: Redirect URL to be set in the OAuth application. - :vartype redirect_url: str - :ivar grant_types: OAuth2 settings. - :vartype grant_types: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2GrantTypes - """ - - _attribute_map = { - "redirect_url": {"key": "redirectUrl", "type": "str"}, - "grant_types": {"key": "grantTypes", "type": "AuthorizationProviderOAuth2GrantTypes"}, - } - - def __init__( - self, - *, - redirect_url: Optional[str] = None, - grant_types: Optional["_models.AuthorizationProviderOAuth2GrantTypes"] = None, - **kwargs: Any - ) -> None: - """ - :keyword redirect_url: Redirect URL to be set in the OAuth application. - :paramtype redirect_url: str - :keyword grant_types: OAuth2 settings. - :paramtype grant_types: ~azure.mgmt.apimanagement.models.AuthorizationProviderOAuth2GrantTypes - """ - super().__init__(**kwargs) - self.redirect_url = redirect_url - self.grant_types = grant_types - - -class AuthorizationServerCollection(_serialization.Model): - """Paged OAuth2 Authorization Servers list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] - :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": "[AuthorizationServerContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.AuthorizationServerContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] - :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 AuthorizationServerContract(ProxyResource): - """External OAuth authorization server settings. - - 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 description: Description of the authorization server. Can contain HTML formatting tags. - :vartype description: str - :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :vartype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :ivar client_authentication_method: Method of authentication supported by the token endpoint of - this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :vartype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :ivar token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :vartype token_endpoint: str - :ivar support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :vartype support_state: bool - :ivar default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :vartype default_scope: str - :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :vartype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :ivar resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :vartype resource_owner_username: str - :ivar resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :vartype resource_owner_password: str - :ivar display_name: User-friendly authorization server name. - :vartype display_name: str - :ivar use_in_test_console: If true, the authorization server may be used in the developer - portal test console. True by default if no value is provided. - :vartype use_in_test_console: bool - :ivar use_in_api_documentation: If true, the authorization server will be used in the API - documentation in the developer portal. False by default if no value is provided. - :vartype use_in_api_documentation: bool - :ivar client_registration_endpoint: Optional reference to a page where client or app - registration for this authorization server is performed. Contains absolute URL to entity being - referenced. - :vartype client_registration_endpoint: str - :ivar authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :vartype authorization_endpoint: str - :ivar grant_types: Form of an authorization grant, which the client uses to request the access - token. - :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :ivar client_id: Client or app id registered with this authorization server. - :vartype client_id: str - :ivar client_secret: Client or app secret registered with this authorization server. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. - :vartype client_secret: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"max_length": 50, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "authorization_methods": {"key": "properties.authorizationMethods", "type": "[str]"}, - "client_authentication_method": {"key": "properties.clientAuthenticationMethod", "type": "[str]"}, - "token_body_parameters": {"key": "properties.tokenBodyParameters", "type": "[TokenBodyParameterContract]"}, - "token_endpoint": {"key": "properties.tokenEndpoint", "type": "str"}, - "support_state": {"key": "properties.supportState", "type": "bool"}, - "default_scope": {"key": "properties.defaultScope", "type": "str"}, - "bearer_token_sending_methods": {"key": "properties.bearerTokenSendingMethods", "type": "[str]"}, - "resource_owner_username": {"key": "properties.resourceOwnerUsername", "type": "str"}, - "resource_owner_password": {"key": "properties.resourceOwnerPassword", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "use_in_test_console": {"key": "properties.useInTestConsole", "type": "bool"}, - "use_in_api_documentation": {"key": "properties.useInApiDocumentation", "type": "bool"}, - "client_registration_endpoint": {"key": "properties.clientRegistrationEndpoint", "type": "str"}, - "authorization_endpoint": {"key": "properties.authorizationEndpoint", "type": "str"}, - "grant_types": {"key": "properties.grantTypes", "type": "[str]"}, - "client_id": {"key": "properties.clientId", "type": "str"}, - "client_secret": {"key": "properties.clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, - token_endpoint: Optional[str] = None, - support_state: Optional[bool] = None, - default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, - resource_owner_username: Optional[str] = None, - resource_owner_password: Optional[str] = None, - display_name: Optional[str] = None, - use_in_test_console: Optional[bool] = None, - use_in_api_documentation: Optional[bool] = None, - client_registration_endpoint: Optional[str] = None, - authorization_endpoint: Optional[str] = None, - grant_types: Optional[List[Union[str, "_models.GrantType"]]] = None, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the authorization server. Can contain HTML formatting - tags. - :paramtype description: str - :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :paramtype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :keyword client_authentication_method: Method of authentication supported by the token endpoint - of this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :paramtype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :keyword token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :paramtype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being - referenced. - :paramtype token_endpoint: str - :keyword support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :paramtype support_state: bool - :keyword default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :paramtype default_scope: str - :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed - to the API. - :paramtype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :keyword resource_owner_username: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner username. - :paramtype resource_owner_username: str - :keyword resource_owner_password: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner password. - :paramtype resource_owner_password: str - :keyword display_name: User-friendly authorization server name. - :paramtype display_name: str - :keyword use_in_test_console: If true, the authorization server may be used in the developer - portal test console. True by default if no value is provided. - :paramtype use_in_test_console: bool - :keyword use_in_api_documentation: If true, the authorization server will be used in the API - documentation in the developer portal. False by default if no value is provided. - :paramtype use_in_api_documentation: bool - :keyword client_registration_endpoint: Optional reference to a page where client or app - registration for this authorization server is performed. Contains absolute URL to entity being - referenced. - :paramtype client_registration_endpoint: str - :keyword authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :paramtype authorization_endpoint: str - :keyword grant_types: Form of an authorization grant, which the client uses to request the - access token. - :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :keyword client_id: Client or app id registered with this authorization server. - :paramtype client_id: str - :keyword client_secret: Client or app secret registered with this authorization server. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. - :paramtype client_secret: str - """ - super().__init__(**kwargs) - self.description = description - self.authorization_methods = authorization_methods - self.client_authentication_method = client_authentication_method - self.token_body_parameters = token_body_parameters - self.token_endpoint = token_endpoint - self.support_state = support_state - self.default_scope = default_scope - self.bearer_token_sending_methods = bearer_token_sending_methods - self.resource_owner_username = resource_owner_username - self.resource_owner_password = resource_owner_password - self.display_name = display_name - self.use_in_test_console = use_in_test_console - self.use_in_api_documentation = use_in_api_documentation - self.client_registration_endpoint = client_registration_endpoint - self.authorization_endpoint = authorization_endpoint - self.grant_types = grant_types - self.client_id = client_id - self.client_secret = client_secret - - -class AuthorizationServerContractBaseProperties(_serialization.Model): # pylint: disable=name-too-long - """External OAuth authorization server Update settings contract. - - :ivar description: Description of the authorization server. Can contain HTML formatting tags. - :vartype description: str - :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :vartype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :ivar client_authentication_method: Method of authentication supported by the token endpoint of - this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :vartype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :ivar token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :vartype token_endpoint: str - :ivar support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :vartype support_state: bool - :ivar default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :vartype default_scope: str - :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :vartype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :ivar resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :vartype resource_owner_username: str - :ivar resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :vartype resource_owner_password: str - """ - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "authorization_methods": {"key": "authorizationMethods", "type": "[str]"}, - "client_authentication_method": {"key": "clientAuthenticationMethod", "type": "[str]"}, - "token_body_parameters": {"key": "tokenBodyParameters", "type": "[TokenBodyParameterContract]"}, - "token_endpoint": {"key": "tokenEndpoint", "type": "str"}, - "support_state": {"key": "supportState", "type": "bool"}, - "default_scope": {"key": "defaultScope", "type": "str"}, - "bearer_token_sending_methods": {"key": "bearerTokenSendingMethods", "type": "[str]"}, - "resource_owner_username": {"key": "resourceOwnerUsername", "type": "str"}, - "resource_owner_password": {"key": "resourceOwnerPassword", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, - token_endpoint: Optional[str] = None, - support_state: Optional[bool] = None, - default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, - resource_owner_username: Optional[str] = None, - resource_owner_password: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the authorization server. Can contain HTML formatting - tags. - :paramtype description: str - :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :paramtype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :keyword client_authentication_method: Method of authentication supported by the token endpoint - of this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :paramtype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :keyword token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :paramtype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being - referenced. - :paramtype token_endpoint: str - :keyword support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :paramtype support_state: bool - :keyword default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :paramtype default_scope: str - :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed - to the API. - :paramtype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :keyword resource_owner_username: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner username. - :paramtype resource_owner_username: str - :keyword resource_owner_password: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner password. - :paramtype resource_owner_password: str - """ - super().__init__(**kwargs) - self.description = description - self.authorization_methods = authorization_methods - self.client_authentication_method = client_authentication_method - self.token_body_parameters = token_body_parameters - self.token_endpoint = token_endpoint - self.support_state = support_state - self.default_scope = default_scope - self.bearer_token_sending_methods = bearer_token_sending_methods - self.resource_owner_username = resource_owner_username - self.resource_owner_password = resource_owner_password - - -class AuthorizationServerContractProperties(AuthorizationServerContractBaseProperties): - """External OAuth authorization server settings Properties. - - All required parameters must be populated in order to send to server. - - :ivar description: Description of the authorization server. Can contain HTML formatting tags. - :vartype description: str - :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :vartype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :ivar client_authentication_method: Method of authentication supported by the token endpoint of - this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :vartype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :ivar token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :vartype token_endpoint: str - :ivar support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :vartype support_state: bool - :ivar default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :vartype default_scope: str - :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :vartype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :ivar resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :vartype resource_owner_username: str - :ivar resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :vartype resource_owner_password: str - :ivar display_name: User-friendly authorization server name. Required. - :vartype display_name: str - :ivar use_in_test_console: If true, the authorization server may be used in the developer - portal test console. True by default if no value is provided. - :vartype use_in_test_console: bool - :ivar use_in_api_documentation: If true, the authorization server will be used in the API - documentation in the developer portal. False by default if no value is provided. - :vartype use_in_api_documentation: bool - :ivar client_registration_endpoint: Optional reference to a page where client or app - registration for this authorization server is performed. Contains absolute URL to entity being - referenced. Required. - :vartype client_registration_endpoint: str - :ivar authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. Required. - :vartype authorization_endpoint: str - :ivar grant_types: Form of an authorization grant, which the client uses to request the access - token. Required. - :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :ivar client_id: Client or app id registered with this authorization server. Required. - :vartype client_id: str - :ivar client_secret: Client or app secret registered with this authorization server. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. - :vartype client_secret: str - """ - - _validation = { - "display_name": {"required": True, "max_length": 50, "min_length": 1}, - "client_registration_endpoint": {"required": True}, - "authorization_endpoint": {"required": True}, - "grant_types": {"required": True}, - "client_id": {"required": True}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "authorization_methods": {"key": "authorizationMethods", "type": "[str]"}, - "client_authentication_method": {"key": "clientAuthenticationMethod", "type": "[str]"}, - "token_body_parameters": {"key": "tokenBodyParameters", "type": "[TokenBodyParameterContract]"}, - "token_endpoint": {"key": "tokenEndpoint", "type": "str"}, - "support_state": {"key": "supportState", "type": "bool"}, - "default_scope": {"key": "defaultScope", "type": "str"}, - "bearer_token_sending_methods": {"key": "bearerTokenSendingMethods", "type": "[str]"}, - "resource_owner_username": {"key": "resourceOwnerUsername", "type": "str"}, - "resource_owner_password": {"key": "resourceOwnerPassword", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "use_in_test_console": {"key": "useInTestConsole", "type": "bool"}, - "use_in_api_documentation": {"key": "useInApiDocumentation", "type": "bool"}, - "client_registration_endpoint": {"key": "clientRegistrationEndpoint", "type": "str"}, - "authorization_endpoint": {"key": "authorizationEndpoint", "type": "str"}, - "grant_types": {"key": "grantTypes", "type": "[str]"}, - "client_id": {"key": "clientId", "type": "str"}, - "client_secret": {"key": "clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - display_name: str, - client_registration_endpoint: str, - authorization_endpoint: str, - grant_types: List[Union[str, "_models.GrantType"]], - client_id: str, - description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, - token_endpoint: Optional[str] = None, - support_state: Optional[bool] = None, - default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, - resource_owner_username: Optional[str] = None, - resource_owner_password: Optional[str] = None, - use_in_test_console: Optional[bool] = None, - use_in_api_documentation: Optional[bool] = None, - client_secret: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the authorization server. Can contain HTML formatting - tags. - :paramtype description: str - :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :paramtype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :keyword client_authentication_method: Method of authentication supported by the token endpoint - of this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :paramtype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :keyword token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :paramtype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being - referenced. - :paramtype token_endpoint: str - :keyword support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :paramtype support_state: bool - :keyword default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :paramtype default_scope: str - :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed - to the API. - :paramtype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :keyword resource_owner_username: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner username. - :paramtype resource_owner_username: str - :keyword resource_owner_password: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner password. - :paramtype resource_owner_password: str - :keyword display_name: User-friendly authorization server name. Required. - :paramtype display_name: str - :keyword use_in_test_console: If true, the authorization server may be used in the developer - portal test console. True by default if no value is provided. - :paramtype use_in_test_console: bool - :keyword use_in_api_documentation: If true, the authorization server will be used in the API - documentation in the developer portal. False by default if no value is provided. - :paramtype use_in_api_documentation: bool - :keyword client_registration_endpoint: Optional reference to a page where client or app - registration for this authorization server is performed. Contains absolute URL to entity being - referenced. Required. - :paramtype client_registration_endpoint: str - :keyword authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. Required. - :paramtype authorization_endpoint: str - :keyword grant_types: Form of an authorization grant, which the client uses to request the - access token. Required. - :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :keyword client_id: Client or app id registered with this authorization server. Required. - :paramtype client_id: str - :keyword client_secret: Client or app secret registered with this authorization server. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. - :paramtype client_secret: str - """ - super().__init__( - description=description, - authorization_methods=authorization_methods, - client_authentication_method=client_authentication_method, - token_body_parameters=token_body_parameters, - token_endpoint=token_endpoint, - support_state=support_state, - default_scope=default_scope, - bearer_token_sending_methods=bearer_token_sending_methods, - resource_owner_username=resource_owner_username, - resource_owner_password=resource_owner_password, - **kwargs - ) - self.display_name = display_name - self.use_in_test_console = use_in_test_console - self.use_in_api_documentation = use_in_api_documentation - self.client_registration_endpoint = client_registration_endpoint - self.authorization_endpoint = authorization_endpoint - self.grant_types = grant_types - self.client_id = client_id - self.client_secret = client_secret - - -class AuthorizationServerSecretsContract(_serialization.Model): - """OAuth Server Secrets Contract. - - :ivar client_secret: oAuth Authorization Server Secrets. - :vartype client_secret: str - :ivar resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :vartype resource_owner_username: str - :ivar resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :vartype resource_owner_password: str - """ - - _attribute_map = { - "client_secret": {"key": "clientSecret", "type": "str"}, - "resource_owner_username": {"key": "resourceOwnerUsername", "type": "str"}, - "resource_owner_password": {"key": "resourceOwnerPassword", "type": "str"}, - } - - def __init__( - self, - *, - client_secret: Optional[str] = None, - resource_owner_username: Optional[str] = None, - resource_owner_password: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword client_secret: oAuth Authorization Server Secrets. - :paramtype client_secret: str - :keyword resource_owner_username: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner username. - :paramtype resource_owner_username: str - :keyword resource_owner_password: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner password. - :paramtype resource_owner_password: str - """ - super().__init__(**kwargs) - self.client_secret = client_secret - self.resource_owner_username = resource_owner_username - self.resource_owner_password = resource_owner_password - - -class AuthorizationServerUpdateContract(ProxyResource): - """External OAuth authorization server settings. - - 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 description: Description of the authorization server. Can contain HTML formatting tags. - :vartype description: str - :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :vartype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :ivar client_authentication_method: Method of authentication supported by the token endpoint of - this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :vartype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :ivar token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :vartype token_endpoint: str - :ivar support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :vartype support_state: bool - :ivar default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :vartype default_scope: str - :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :vartype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :ivar resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :vartype resource_owner_username: str - :ivar resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :vartype resource_owner_password: str - :ivar display_name: User-friendly authorization server name. - :vartype display_name: str - :ivar use_in_test_console: If true, the authorization server may be used in the developer - portal test console. True by default if no value is provided. - :vartype use_in_test_console: bool - :ivar use_in_api_documentation: If true, the authorization server will be used in the API - documentation in the developer portal. False by default if no value is provided. - :vartype use_in_api_documentation: bool - :ivar client_registration_endpoint: Optional reference to a page where client or app - registration for this authorization server is performed. Contains absolute URL to entity being - referenced. - :vartype client_registration_endpoint: str - :ivar authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :vartype authorization_endpoint: str - :ivar grant_types: Form of an authorization grant, which the client uses to request the access - token. - :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :ivar client_id: Client or app id registered with this authorization server. - :vartype client_id: str - :ivar client_secret: Client or app secret registered with this authorization server. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. - :vartype client_secret: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"max_length": 50, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "authorization_methods": {"key": "properties.authorizationMethods", "type": "[str]"}, - "client_authentication_method": {"key": "properties.clientAuthenticationMethod", "type": "[str]"}, - "token_body_parameters": {"key": "properties.tokenBodyParameters", "type": "[TokenBodyParameterContract]"}, - "token_endpoint": {"key": "properties.tokenEndpoint", "type": "str"}, - "support_state": {"key": "properties.supportState", "type": "bool"}, - "default_scope": {"key": "properties.defaultScope", "type": "str"}, - "bearer_token_sending_methods": {"key": "properties.bearerTokenSendingMethods", "type": "[str]"}, - "resource_owner_username": {"key": "properties.resourceOwnerUsername", "type": "str"}, - "resource_owner_password": {"key": "properties.resourceOwnerPassword", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "use_in_test_console": {"key": "properties.useInTestConsole", "type": "bool"}, - "use_in_api_documentation": {"key": "properties.useInApiDocumentation", "type": "bool"}, - "client_registration_endpoint": {"key": "properties.clientRegistrationEndpoint", "type": "str"}, - "authorization_endpoint": {"key": "properties.authorizationEndpoint", "type": "str"}, - "grant_types": {"key": "properties.grantTypes", "type": "[str]"}, - "client_id": {"key": "properties.clientId", "type": "str"}, - "client_secret": {"key": "properties.clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, - token_endpoint: Optional[str] = None, - support_state: Optional[bool] = None, - default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, - resource_owner_username: Optional[str] = None, - resource_owner_password: Optional[str] = None, - display_name: Optional[str] = None, - use_in_test_console: Optional[bool] = None, - use_in_api_documentation: Optional[bool] = None, - client_registration_endpoint: Optional[str] = None, - authorization_endpoint: Optional[str] = None, - grant_types: Optional[List[Union[str, "_models.GrantType"]]] = None, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the authorization server. Can contain HTML formatting - tags. - :paramtype description: str - :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :paramtype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :keyword client_authentication_method: Method of authentication supported by the token endpoint - of this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :paramtype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :keyword token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :paramtype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being - referenced. - :paramtype token_endpoint: str - :keyword support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :paramtype support_state: bool - :keyword default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :paramtype default_scope: str - :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed - to the API. - :paramtype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :keyword resource_owner_username: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner username. - :paramtype resource_owner_username: str - :keyword resource_owner_password: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner password. - :paramtype resource_owner_password: str - :keyword display_name: User-friendly authorization server name. - :paramtype display_name: str - :keyword use_in_test_console: If true, the authorization server may be used in the developer - portal test console. True by default if no value is provided. - :paramtype use_in_test_console: bool - :keyword use_in_api_documentation: If true, the authorization server will be used in the API - documentation in the developer portal. False by default if no value is provided. - :paramtype use_in_api_documentation: bool - :keyword client_registration_endpoint: Optional reference to a page where client or app - registration for this authorization server is performed. Contains absolute URL to entity being - referenced. - :paramtype client_registration_endpoint: str - :keyword authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :paramtype authorization_endpoint: str - :keyword grant_types: Form of an authorization grant, which the client uses to request the - access token. - :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :keyword client_id: Client or app id registered with this authorization server. - :paramtype client_id: str - :keyword client_secret: Client or app secret registered with this authorization server. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. - :paramtype client_secret: str - """ - super().__init__(**kwargs) - self.description = description - self.authorization_methods = authorization_methods - self.client_authentication_method = client_authentication_method - self.token_body_parameters = token_body_parameters - self.token_endpoint = token_endpoint - self.support_state = support_state - self.default_scope = default_scope - self.bearer_token_sending_methods = bearer_token_sending_methods - self.resource_owner_username = resource_owner_username - self.resource_owner_password = resource_owner_password - self.display_name = display_name - self.use_in_test_console = use_in_test_console - self.use_in_api_documentation = use_in_api_documentation - self.client_registration_endpoint = client_registration_endpoint - self.authorization_endpoint = authorization_endpoint - self.grant_types = grant_types - self.client_id = client_id - self.client_secret = client_secret - - -class AuthorizationServerUpdateContractProperties( - AuthorizationServerContractBaseProperties -): # pylint: disable=name-too-long - """External OAuth authorization server Update settings contract. - - :ivar description: Description of the authorization server. Can contain HTML formatting tags. - :vartype description: str - :ivar authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :vartype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :ivar client_authentication_method: Method of authentication supported by the token endpoint of - this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :vartype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :ivar token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :vartype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :ivar token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. - :vartype token_endpoint: str - :ivar support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :vartype support_state: bool - :ivar default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :vartype default_scope: str - :ivar bearer_token_sending_methods: Specifies the mechanism by which access token is passed to - the API. - :vartype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :ivar resource_owner_username: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner username. - :vartype resource_owner_username: str - :ivar resource_owner_password: Can be optionally specified when resource owner password grant - type is supported by this authorization server. Default resource owner password. - :vartype resource_owner_password: str - :ivar display_name: User-friendly authorization server name. - :vartype display_name: str - :ivar use_in_test_console: If true, the authorization server may be used in the developer - portal test console. True by default if no value is provided. - :vartype use_in_test_console: bool - :ivar use_in_api_documentation: If true, the authorization server will be used in the API - documentation in the developer portal. False by default if no value is provided. - :vartype use_in_api_documentation: bool - :ivar client_registration_endpoint: Optional reference to a page where client or app - registration for this authorization server is performed. Contains absolute URL to entity being - referenced. - :vartype client_registration_endpoint: str - :ivar authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :vartype authorization_endpoint: str - :ivar grant_types: Form of an authorization grant, which the client uses to request the access - token. - :vartype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :ivar client_id: Client or app id registered with this authorization server. - :vartype client_id: str - :ivar client_secret: Client or app secret registered with this authorization server. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. - :vartype client_secret: str - """ - - _validation = { - "display_name": {"max_length": 50, "min_length": 1}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "authorization_methods": {"key": "authorizationMethods", "type": "[str]"}, - "client_authentication_method": {"key": "clientAuthenticationMethod", "type": "[str]"}, - "token_body_parameters": {"key": "tokenBodyParameters", "type": "[TokenBodyParameterContract]"}, - "token_endpoint": {"key": "tokenEndpoint", "type": "str"}, - "support_state": {"key": "supportState", "type": "bool"}, - "default_scope": {"key": "defaultScope", "type": "str"}, - "bearer_token_sending_methods": {"key": "bearerTokenSendingMethods", "type": "[str]"}, - "resource_owner_username": {"key": "resourceOwnerUsername", "type": "str"}, - "resource_owner_password": {"key": "resourceOwnerPassword", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "use_in_test_console": {"key": "useInTestConsole", "type": "bool"}, - "use_in_api_documentation": {"key": "useInApiDocumentation", "type": "bool"}, - "client_registration_endpoint": {"key": "clientRegistrationEndpoint", "type": "str"}, - "authorization_endpoint": {"key": "authorizationEndpoint", "type": "str"}, - "grant_types": {"key": "grantTypes", "type": "[str]"}, - "client_id": {"key": "clientId", "type": "str"}, - "client_secret": {"key": "clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - authorization_methods: Optional[List[Union[str, "_models.AuthorizationMethod"]]] = None, - client_authentication_method: Optional[List[Union[str, "_models.ClientAuthenticationMethod"]]] = None, - token_body_parameters: Optional[List["_models.TokenBodyParameterContract"]] = None, - token_endpoint: Optional[str] = None, - support_state: Optional[bool] = None, - default_scope: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethod"]]] = None, - resource_owner_username: Optional[str] = None, - resource_owner_password: Optional[str] = None, - display_name: Optional[str] = None, - use_in_test_console: Optional[bool] = None, - use_in_api_documentation: Optional[bool] = None, - client_registration_endpoint: Optional[str] = None, - authorization_endpoint: Optional[str] = None, - grant_types: Optional[List[Union[str, "_models.GrantType"]]] = None, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the authorization server. Can contain HTML formatting - tags. - :paramtype description: str - :keyword authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be - always present. POST is optional. - :paramtype authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :keyword client_authentication_method: Method of authentication supported by the token endpoint - of this authorization server. Possible values are Basic and/or Body. When Body is specified, - client credentials and other parameters are passed within the request body in the - application/x-www-form-urlencoded format. - :paramtype client_authentication_method: list[str or - ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :keyword token_body_parameters: Additional parameters required by the token endpoint of this - authorization server represented as an array of JSON objects with name and value string - properties, i.e. {"name" : "name value", "value": "a value"}. - :paramtype token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :keyword token_endpoint: OAuth token endpoint. Contains absolute URI to entity being - referenced. - :paramtype token_endpoint: str - :keyword support_state: If true, authorization server will include state parameter from the - authorization request to its response. Client may use state parameter to raise protocol - security. - :paramtype support_state: bool - :keyword default_scope: Access token scope that is going to be requested by default. Can be - overridden at the API level. Should be provided in the form of a string containing - space-delimited values. - :paramtype default_scope: str - :keyword bearer_token_sending_methods: Specifies the mechanism by which access token is passed - to the API. - :paramtype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :keyword resource_owner_username: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner username. - :paramtype resource_owner_username: str - :keyword resource_owner_password: Can be optionally specified when resource owner password - grant type is supported by this authorization server. Default resource owner password. - :paramtype resource_owner_password: str - :keyword display_name: User-friendly authorization server name. - :paramtype display_name: str - :keyword use_in_test_console: If true, the authorization server may be used in the developer - portal test console. True by default if no value is provided. - :paramtype use_in_test_console: bool - :keyword use_in_api_documentation: If true, the authorization server will be used in the API - documentation in the developer portal. False by default if no value is provided. - :paramtype use_in_api_documentation: bool - :keyword client_registration_endpoint: Optional reference to a page where client or app - registration for this authorization server is performed. Contains absolute URL to entity being - referenced. - :paramtype client_registration_endpoint: str - :keyword authorization_endpoint: OAuth authorization endpoint. See - http://tools.ietf.org/html/rfc6749#section-3.2. - :paramtype authorization_endpoint: str - :keyword grant_types: Form of an authorization grant, which the client uses to request the - access token. - :paramtype grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :keyword client_id: Client or app id registered with this authorization server. - :paramtype client_id: str - :keyword client_secret: Client or app secret registered with this authorization server. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. - :paramtype client_secret: str - """ - super().__init__( - description=description, - authorization_methods=authorization_methods, - client_authentication_method=client_authentication_method, - token_body_parameters=token_body_parameters, - token_endpoint=token_endpoint, - support_state=support_state, - default_scope=default_scope, - bearer_token_sending_methods=bearer_token_sending_methods, - resource_owner_username=resource_owner_username, - resource_owner_password=resource_owner_password, - **kwargs - ) - self.display_name = display_name - self.use_in_test_console = use_in_test_console - self.use_in_api_documentation = use_in_api_documentation - self.client_registration_endpoint = client_registration_endpoint - self.authorization_endpoint = authorization_endpoint - self.grant_types = grant_types - self.client_id = client_id - self.client_secret = client_secret - - -class BackendAuthorizationHeaderCredentials(_serialization.Model): - """Authorization header information. - - All required parameters must be populated in order to send to server. - - :ivar scheme: Authentication Scheme name. Required. - :vartype scheme: str - :ivar parameter: Authentication Parameter value. Required. - :vartype parameter: str - """ - - _validation = { - "scheme": {"required": True, "max_length": 100, "min_length": 1}, - "parameter": {"required": True, "max_length": 300, "min_length": 1}, - } - - _attribute_map = { - "scheme": {"key": "scheme", "type": "str"}, - "parameter": {"key": "parameter", "type": "str"}, - } - - def __init__(self, *, scheme: str, parameter: str, **kwargs: Any) -> None: - """ - :keyword scheme: Authentication Scheme name. Required. - :paramtype scheme: str - :keyword parameter: Authentication Parameter value. Required. - :paramtype parameter: str - """ - super().__init__(**kwargs) - self.scheme = scheme - self.parameter = parameter - - -class BackendBaseParameters(_serialization.Model): - """Backend entity base Parameter set. - - :ivar title: Backend Title. - :vartype title: str - :ivar description: Backend Description. - :vartype description: str - :ivar resource_id: Management Uri of the Resource in External System. This URL can be the Arm - Resource Id of Logic Apps, Function Apps or API Apps. - :vartype resource_id: str - :ivar properties: Backend Properties contract. - :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :ivar proxy: Backend gateway Contract Properties. - :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 = { - "title": {"max_length": 300, "min_length": 1}, - "description": {"max_length": 2000, "min_length": 1}, - "resource_id": {"max_length": 2000, "min_length": 1}, - } - - _attribute_map = { - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "properties": {"key": "properties", "type": "BackendProperties"}, - "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__( - self, - *, - title: Optional[str] = None, - description: Optional[str] = None, - resource_id: Optional[str] = None, - properties: Optional["_models.BackendProperties"] = None, - 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: - """ - :keyword title: Backend Title. - :paramtype title: str - :keyword description: Backend Description. - :paramtype description: str - :keyword resource_id: Management Uri of the Resource in External System. This URL can be the - Arm Resource Id of Logic Apps, Function Apps or API Apps. - :paramtype resource_id: str - :keyword properties: Backend Properties contract. - :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :keyword proxy: Backend gateway Contract Properties. - :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 - self.description = description - self.resource_id = resource_id - self.properties = properties - 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): - """Paged Backend list representation. - - :ivar value: Backend values. - :vartype value: list[~azure.mgmt.apimanagement.models.BackendContract] - :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": "[BackendContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.BackendContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Backend values. - :paramtype value: list[~azure.mgmt.apimanagement.models.BackendContract] - :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 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): - """Backend 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 title: Backend Title. - :vartype title: str - :ivar description: Backend Description. - :vartype description: str - :ivar resource_id: Management Uri of the Resource in External System. This URL can be the Arm - Resource Id of Logic Apps, Function Apps or API Apps. - :vartype resource_id: str - :ivar properties: Backend Properties contract. - :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :ivar proxy: Backend gateway Contract Properties. - :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". - :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "title": {"max_length": 300, "min_length": 1}, - "description": {"max_length": 2000, "min_length": 1}, - "resource_id": {"max_length": 2000, "min_length": 1}, - "url": {"max_length": 2000, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "title": {"key": "properties.title", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "resource_id": {"key": "properties.resourceId", "type": "str"}, - "properties": {"key": "properties.properties", "type": "BackendProperties"}, - "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"}, - } - - def __init__( - self, - *, - title: Optional[str] = None, - description: Optional[str] = None, - resource_id: Optional[str] = None, - properties: Optional["_models.BackendProperties"] = None, - 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 - ) -> None: - """ - :keyword title: Backend Title. - :paramtype title: str - :keyword description: Backend Description. - :paramtype description: str - :keyword resource_id: Management Uri of the Resource in External System. This URL can be the - Arm Resource Id of Logic Apps, Function Apps or API Apps. - :paramtype resource_id: str - :keyword properties: Backend Properties contract. - :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :keyword proxy: Backend gateway Contract Properties. - :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". - :paramtype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - super().__init__(**kwargs) - self.title = title - self.description = description - self.resource_id = resource_id - self.properties = properties - 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): - """Parameters supplied to the Create Backend operation. - - All required parameters must be populated in order to send to server. - - :ivar title: Backend Title. - :vartype title: str - :ivar description: Backend Description. - :vartype description: str - :ivar resource_id: Management Uri of the Resource in External System. This URL can be the Arm - Resource Id of Logic Apps, Function Apps or API Apps. - :vartype resource_id: str - :ivar properties: Backend Properties contract. - :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :ivar proxy: Backend gateway Contract Properties. - :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". - :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - - _validation = { - "title": {"max_length": 300, "min_length": 1}, - "description": {"max_length": 2000, "min_length": 1}, - "resource_id": {"max_length": 2000, "min_length": 1}, - "url": {"required": True, "max_length": 2000, "min_length": 1}, - "protocol": {"required": True}, - } - - _attribute_map = { - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "properties": {"key": "properties", "type": "BackendProperties"}, - "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"}, - } - - def __init__( - self, - *, - url: str, - protocol: Union[str, "_models.BackendProtocol"], - title: Optional[str] = None, - description: Optional[str] = None, - resource_id: Optional[str] = None, - properties: Optional["_models.BackendProperties"] = None, - 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: - """ - :keyword title: Backend Title. - :paramtype title: str - :keyword description: Backend Description. - :paramtype description: str - :keyword resource_id: Management Uri of the Resource in External System. This URL can be the - Arm Resource Id of Logic Apps, Function Apps or API Apps. - :paramtype resource_id: str - :keyword properties: Backend Properties contract. - :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :keyword proxy: Backend gateway Contract Properties. - :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 - "soap". - :paramtype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - super().__init__( - title=title, - description=description, - resource_id=resource_id, - properties=properties, - credentials=credentials, - proxy=proxy, - tls=tls, - circuit_breaker=circuit_breaker, - pool=pool, - type=type, - **kwargs - ) - self.url = url - self.protocol = protocol - - -class BackendCredentialsContract(_serialization.Model): - """Details of the Credentials used to connect to Backend. - - :ivar certificate_ids: List of Client Certificate Ids. - :vartype certificate_ids: list[str] - :ivar certificate: List of Client Certificate Thumbprints. Will be ignored if certificatesIds - are provided. - :vartype certificate: list[str] - :ivar query: Query Parameter description. - :vartype query: dict[str, list[str]] - :ivar header: Header Parameter description. - :vartype header: dict[str, list[str]] - :ivar authorization: Authorization header authentication. - :vartype authorization: ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials - """ - - _validation = { - "certificate_ids": {"max_items": 32, "min_items": 0}, - "certificate": {"max_items": 32, "min_items": 0}, - } - - _attribute_map = { - "certificate_ids": {"key": "certificateIds", "type": "[str]"}, - "certificate": {"key": "certificate", "type": "[str]"}, - "query": {"key": "query", "type": "{[str]}"}, - "header": {"key": "header", "type": "{[str]}"}, - "authorization": {"key": "authorization", "type": "BackendAuthorizationHeaderCredentials"}, - } - - def __init__( - self, - *, - certificate_ids: Optional[List[str]] = None, - certificate: Optional[List[str]] = None, - query: Optional[Dict[str, List[str]]] = None, - header: Optional[Dict[str, List[str]]] = None, - authorization: Optional["_models.BackendAuthorizationHeaderCredentials"] = None, - **kwargs: Any - ) -> None: - """ - :keyword certificate_ids: List of Client Certificate Ids. - :paramtype certificate_ids: list[str] - :keyword certificate: List of Client Certificate Thumbprints. Will be ignored if - certificatesIds are provided. - :paramtype certificate: list[str] - :keyword query: Query Parameter description. - :paramtype query: dict[str, list[str]] - :keyword header: Header Parameter description. - :paramtype header: dict[str, list[str]] - :keyword authorization: Authorization header authentication. - :paramtype authorization: - ~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 - - -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): - """Properties specific to the Backend Type. - - :ivar service_fabric_cluster: Backend Service Fabric Cluster Properties. - :vartype service_fabric_cluster: - ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties - """ - - _attribute_map = { - "service_fabric_cluster": {"key": "serviceFabricCluster", "type": "BackendServiceFabricClusterProperties"}, - } - - def __init__( - self, *, service_fabric_cluster: Optional["_models.BackendServiceFabricClusterProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword service_fabric_cluster: Backend Service Fabric Cluster Properties. - :paramtype service_fabric_cluster: - ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties - """ - super().__init__(**kwargs) - self.service_fabric_cluster = service_fabric_cluster - - -class BackendProxyContract(_serialization.Model): - """Details of the Backend WebProxy Server to use in the Request to Backend. - - All required parameters must be populated in order to send to server. - - :ivar url: WebProxy Server AbsoluteUri property which includes the entire URI stored in the Uri - instance, including all fragments and query strings. Required. - :vartype url: str - :ivar username: Username to connect to the WebProxy server. - :vartype username: str - :ivar password: Password to connect to the WebProxy Server. - :vartype password: str - """ - - _validation = { - "url": {"required": True, "max_length": 2000, "min_length": 1}, - } - - _attribute_map = { - "url": {"key": "url", "type": "str"}, - "username": {"key": "username", "type": "str"}, - "password": {"key": "password", "type": "str"}, - } - - def __init__( - self, *, url: str, username: Optional[str] = None, password: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword url: WebProxy Server AbsoluteUri property which includes the entire URI stored in the - Uri instance, including all fragments and query strings. Required. - :paramtype url: str - :keyword username: Username to connect to the WebProxy server. - :paramtype username: str - :keyword password: Password to connect to the WebProxy Server. - :paramtype password: str - """ - super().__init__(**kwargs) - self.url = url - self.username = username - self.password = password - - -class BackendReconnectContract(ProxyResource): - """Reconnect request parameters. - - 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 after: Duration in ISO8601 format after which reconnect will be initiated. Minimum - duration of the Reconnect is PT2M. - :vartype after: ~datetime.timedelta - """ - - _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"}, - "after": {"key": "properties.after", "type": "duration"}, - } - - def __init__(self, *, after: Optional[datetime.timedelta] = None, **kwargs: Any) -> None: - """ - :keyword after: Duration in ISO8601 format after which reconnect will be initiated. Minimum - duration of the Reconnect is PT2M. - :paramtype after: ~datetime.timedelta - """ - super().__init__(**kwargs) - self.after = after - - -class BackendServiceFabricClusterProperties(_serialization.Model): - """Properties of the Service Fabric Type Backend. - - All required parameters must be populated in order to send to server. - - :ivar client_certificate_id: The client certificate id for the management endpoint. - :vartype client_certificate_id: str - :ivar client_certificatethumbprint: The client certificate thumbprint for the management - endpoint. Will be ignored if certificatesIds are provided. - :vartype client_certificatethumbprint: str - :ivar max_partition_resolution_retries: Maximum number of retries while attempting resolve the - partition. - :vartype max_partition_resolution_retries: int - :ivar management_endpoints: The cluster management endpoint. Required. - :vartype management_endpoints: list[str] - :ivar server_certificate_thumbprints: Thumbprints of certificates cluster management service - uses for tls communication. - :vartype server_certificate_thumbprints: list[str] - :ivar server_x509_names: Server X509 Certificate Names Collection. - :vartype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] - """ - - _validation = { - "management_endpoints": {"required": True}, - } - - _attribute_map = { - "client_certificate_id": {"key": "clientCertificateId", "type": "str"}, - "client_certificatethumbprint": {"key": "clientCertificatethumbprint", "type": "str"}, - "max_partition_resolution_retries": {"key": "maxPartitionResolutionRetries", "type": "int"}, - "management_endpoints": {"key": "managementEndpoints", "type": "[str]"}, - "server_certificate_thumbprints": {"key": "serverCertificateThumbprints", "type": "[str]"}, - "server_x509_names": {"key": "serverX509Names", "type": "[X509CertificateName]"}, - } - - def __init__( - self, - *, - management_endpoints: List[str], - client_certificate_id: Optional[str] = None, - client_certificatethumbprint: Optional[str] = None, - max_partition_resolution_retries: Optional[int] = None, - server_certificate_thumbprints: Optional[List[str]] = None, - server_x509_names: Optional[List["_models.X509CertificateName"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword client_certificate_id: The client certificate id for the management endpoint. - :paramtype client_certificate_id: str - :keyword client_certificatethumbprint: The client certificate thumbprint for the management - endpoint. Will be ignored if certificatesIds are provided. - :paramtype client_certificatethumbprint: str - :keyword max_partition_resolution_retries: Maximum number of retries while attempting resolve - the partition. - :paramtype max_partition_resolution_retries: int - :keyword management_endpoints: The cluster management endpoint. Required. - :paramtype management_endpoints: list[str] - :keyword server_certificate_thumbprints: Thumbprints of certificates cluster management service - uses for tls communication. - :paramtype server_certificate_thumbprints: list[str] - :keyword server_x509_names: Server X509 Certificate Names Collection. - :paramtype server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] - """ - super().__init__(**kwargs) - self.client_certificate_id = client_certificate_id - self.client_certificatethumbprint = client_certificatethumbprint - self.max_partition_resolution_retries = max_partition_resolution_retries - self.management_endpoints = management_endpoints - self.server_certificate_thumbprints = server_certificate_thumbprints - 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. - - :ivar validate_certificate_chain: Flag indicating whether SSL certificate chain validation - should be done when using self-signed certificates for this backend host. - :vartype validate_certificate_chain: bool - :ivar validate_certificate_name: Flag indicating whether SSL certificate name validation should - be done when using self-signed certificates for this backend host. - :vartype validate_certificate_name: bool - """ - - _attribute_map = { - "validate_certificate_chain": {"key": "validateCertificateChain", "type": "bool"}, - "validate_certificate_name": {"key": "validateCertificateName", "type": "bool"}, - } - - def __init__( - self, *, validate_certificate_chain: bool = True, validate_certificate_name: bool = True, **kwargs: Any - ) -> None: - """ - :keyword validate_certificate_chain: Flag indicating whether SSL certificate chain validation - should be done when using self-signed certificates for this backend host. - :paramtype validate_certificate_chain: bool - :keyword validate_certificate_name: Flag indicating whether SSL certificate name validation - should be done when using self-signed certificates for this backend host. - :paramtype validate_certificate_name: bool - """ - super().__init__(**kwargs) - self.validate_certificate_chain = validate_certificate_chain - self.validate_certificate_name = validate_certificate_name - - -class BackendUpdateParameterProperties(BackendBaseParameters): - """Parameters supplied to the Update Backend operation. - - :ivar title: Backend Title. - :vartype title: str - :ivar description: Backend Description. - :vartype description: str - :ivar resource_id: Management Uri of the Resource in External System. This URL can be the Arm - Resource Id of Logic Apps, Function Apps or API Apps. - :vartype resource_id: str - :ivar properties: Backend Properties contract. - :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :ivar proxy: Backend gateway Contract Properties. - :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". - :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - - _validation = { - "title": {"max_length": 300, "min_length": 1}, - "description": {"max_length": 2000, "min_length": 1}, - "resource_id": {"max_length": 2000, "min_length": 1}, - "url": {"max_length": 2000, "min_length": 1}, - } - - _attribute_map = { - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "properties": {"key": "properties", "type": "BackendProperties"}, - "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"}, - } - - def __init__( - self, - *, - title: Optional[str] = None, - description: Optional[str] = None, - resource_id: Optional[str] = None, - properties: Optional["_models.BackendProperties"] = None, - 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 - ) -> None: - """ - :keyword title: Backend Title. - :paramtype title: str - :keyword description: Backend Description. - :paramtype description: str - :keyword resource_id: Management Uri of the Resource in External System. This URL can be the - Arm Resource Id of Logic Apps, Function Apps or API Apps. - :paramtype resource_id: str - :keyword properties: Backend Properties contract. - :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :keyword proxy: Backend gateway Contract Properties. - :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". - :paramtype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - super().__init__( - title=title, - description=description, - resource_id=resource_id, - properties=properties, - 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): - """Backend update parameters. - - :ivar title: Backend Title. - :vartype title: str - :ivar description: Backend Description. - :vartype description: str - :ivar resource_id: Management Uri of the Resource in External System. This URL can be the Arm - Resource Id of Logic Apps, Function Apps or API Apps. - :vartype resource_id: str - :ivar properties: Backend Properties contract. - :vartype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :ivar credentials: Backend Credentials Contract Properties. - :vartype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :ivar proxy: Backend gateway Contract Properties. - :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". - :vartype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - - _validation = { - "title": {"max_length": 300, "min_length": 1}, - "description": {"max_length": 2000, "min_length": 1}, - "resource_id": {"max_length": 2000, "min_length": 1}, - "url": {"max_length": 2000, "min_length": 1}, - } - - _attribute_map = { - "title": {"key": "properties.title", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "resource_id": {"key": "properties.resourceId", "type": "str"}, - "properties": {"key": "properties.properties", "type": "BackendProperties"}, - "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"}, - } - - def __init__( - self, - *, - title: Optional[str] = None, - description: Optional[str] = None, - resource_id: Optional[str] = None, - properties: Optional["_models.BackendProperties"] = None, - 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 - ) -> None: - """ - :keyword title: Backend Title. - :paramtype title: str - :keyword description: Backend Description. - :paramtype description: str - :keyword resource_id: Management Uri of the Resource in External System. This URL can be the - Arm Resource Id of Logic Apps, Function Apps or API Apps. - :paramtype resource_id: str - :keyword properties: Backend Properties contract. - :paramtype properties: ~azure.mgmt.apimanagement.models.BackendProperties - :keyword credentials: Backend Credentials Contract Properties. - :paramtype credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :keyword proxy: Backend gateway Contract Properties. - :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". - :paramtype protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol - """ - super().__init__(**kwargs) - self.title = title - self.description = description - self.resource_id = resource_id - self.properties = properties - 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 - - -class BodyDiagnosticSettings(_serialization.Model): - """Body logging settings. - - :ivar bytes: Number of request body bytes to log. - :vartype bytes: int - """ - - _validation = { - "bytes": {"maximum": 8192}, - } - - _attribute_map = { - "bytes": {"key": "bytes", "type": "int"}, - } - - def __init__(self, *, bytes: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword bytes: Number of request body bytes to log. - :paramtype bytes: int - """ - super().__init__(**kwargs) - self.bytes = bytes - - -class CacheCollection(_serialization.Model): - """Paged Caches list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.CacheContract] - :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": "[CacheContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.CacheContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.CacheContract] - :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 CacheContract(ProxyResource): - """Cache 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 description: Cache description. - :vartype description: str - :ivar connection_string: Runtime connection string to cache. - :vartype connection_string: str - :ivar use_from_location: Location identifier to use cache from (should be either 'default' or - valid Azure region identifier). - :vartype use_from_location: str - :ivar resource_id: Original uri of entity in external system cache points to. - :vartype resource_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "description": {"max_length": 2000}, - "connection_string": {"max_length": 300}, - "use_from_location": {"max_length": 256}, - "resource_id": {"max_length": 2000}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "connection_string": {"key": "properties.connectionString", "type": "str"}, - "use_from_location": {"key": "properties.useFromLocation", "type": "str"}, - "resource_id": {"key": "properties.resourceId", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - connection_string: Optional[str] = None, - use_from_location: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Cache description. - :paramtype description: str - :keyword connection_string: Runtime connection string to cache. - :paramtype connection_string: str - :keyword use_from_location: Location identifier to use cache from (should be either 'default' - or valid Azure region identifier). - :paramtype use_from_location: str - :keyword resource_id: Original uri of entity in external system cache points to. - :paramtype resource_id: str - """ - super().__init__(**kwargs) - self.description = description - self.connection_string = connection_string - self.use_from_location = use_from_location - self.resource_id = resource_id - - -class CacheUpdateParameters(_serialization.Model): - """Cache update details. - - :ivar description: Cache description. - :vartype description: str - :ivar connection_string: Runtime connection string to cache. - :vartype connection_string: str - :ivar use_from_location: Location identifier to use cache from (should be either 'default' or - valid Azure region identifier). - :vartype use_from_location: str - :ivar resource_id: Original uri of entity in external system cache points to. - :vartype resource_id: str - """ - - _validation = { - "description": {"max_length": 2000}, - "connection_string": {"max_length": 300}, - "use_from_location": {"max_length": 256}, - "resource_id": {"max_length": 2000}, - } - - _attribute_map = { - "description": {"key": "properties.description", "type": "str"}, - "connection_string": {"key": "properties.connectionString", "type": "str"}, - "use_from_location": {"key": "properties.useFromLocation", "type": "str"}, - "resource_id": {"key": "properties.resourceId", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - connection_string: Optional[str] = None, - use_from_location: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Cache description. - :paramtype description: str - :keyword connection_string: Runtime connection string to cache. - :paramtype connection_string: str - :keyword use_from_location: Location identifier to use cache from (should be either 'default' - or valid Azure region identifier). - :paramtype use_from_location: str - :keyword resource_id: Original uri of entity in external system cache points to. - :paramtype resource_id: str - """ - super().__init__(**kwargs) - self.description = description - self.connection_string = connection_string - self.use_from_location = use_from_location - self.resource_id = resource_id - - -class CertificateCollection(_serialization.Model): - """Paged Certificates list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.CertificateContract] - :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": "[CertificateContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.CertificateContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.CertificateContract] - :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 CertificateConfiguration(_serialization.Model): - """Certificate configuration which consist of non-trusted intermediates and root certificates. - - All required parameters must be populated in order to send to server. - - :ivar encoded_certificate: Base64 Encoded certificate. - :vartype encoded_certificate: str - :ivar certificate_password: Certificate Password. - :vartype certificate_password: str - :ivar store_name: The System.Security.Cryptography.x509certificates.StoreName certificate store - location. Only Root and CertificateAuthority are valid locations. Required. Known values are: - "CertificateAuthority" and "Root". - :vartype store_name: str or ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName - :ivar certificate: Certificate information. - :vartype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation - """ - - _validation = { - "store_name": {"required": True}, - } - - _attribute_map = { - "encoded_certificate": {"key": "encodedCertificate", "type": "str"}, - "certificate_password": {"key": "certificatePassword", "type": "str"}, - "store_name": {"key": "storeName", "type": "str"}, - "certificate": {"key": "certificate", "type": "CertificateInformation"}, - } - - def __init__( - self, - *, - store_name: Union[str, "_models.CertificateConfigurationStoreName"], - encoded_certificate: Optional[str] = None, - certificate_password: Optional[str] = None, - certificate: Optional["_models.CertificateInformation"] = None, - **kwargs: Any - ) -> None: - """ - :keyword encoded_certificate: Base64 Encoded certificate. - :paramtype encoded_certificate: str - :keyword certificate_password: Certificate Password. - :paramtype certificate_password: str - :keyword store_name: The System.Security.Cryptography.x509certificates.StoreName certificate - store location. Only Root and CertificateAuthority are valid locations. Required. Known values - are: "CertificateAuthority" and "Root". - :paramtype store_name: str or - ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName - :keyword certificate: Certificate information. - :paramtype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation - """ - super().__init__(**kwargs) - self.encoded_certificate = encoded_certificate - self.certificate_password = certificate_password - self.store_name = store_name - self.certificate = certificate - - -class CertificateContract(ProxyResource): - """Certificate 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 subject: Subject attribute of the certificate. - :vartype subject: str - :ivar thumbprint: Thumbprint of the certificate. - :vartype thumbprint: str - :ivar expiration_date: Expiration date of the certificate. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype expiration_date: ~datetime.datetime - :ivar key_vault: KeyVault location details of the certificate. - :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties - """ - - _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"}, - "subject": {"key": "properties.subject", "type": "str"}, - "thumbprint": {"key": "properties.thumbprint", "type": "str"}, - "expiration_date": {"key": "properties.expirationDate", "type": "iso-8601"}, - "key_vault": {"key": "properties.keyVault", "type": "KeyVaultContractProperties"}, - } - - def __init__( - self, - *, - subject: Optional[str] = None, - thumbprint: Optional[str] = None, - expiration_date: Optional[datetime.datetime] = None, - key_vault: Optional["_models.KeyVaultContractProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword subject: Subject attribute of the certificate. - :paramtype subject: str - :keyword thumbprint: Thumbprint of the certificate. - :paramtype thumbprint: str - :keyword expiration_date: Expiration date of the certificate. The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype expiration_date: ~datetime.datetime - :keyword key_vault: KeyVault location details of the certificate. - :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties - """ - super().__init__(**kwargs) - self.subject = subject - self.thumbprint = thumbprint - self.expiration_date = expiration_date - self.key_vault = key_vault - - -class CertificateCreateOrUpdateParameters(_serialization.Model): - """Certificate create or update details. - - :ivar data: Base 64 encoded certificate using the application/x-pkcs12 representation. - :vartype data: str - :ivar password: Password for the Certificate. - :vartype password: str - :ivar key_vault: KeyVault location details of the certificate. - :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - - _attribute_map = { - "data": {"key": "properties.data", "type": "str"}, - "password": {"key": "properties.password", "type": "str"}, - "key_vault": {"key": "properties.keyVault", "type": "KeyVaultContractCreateProperties"}, - } - - def __init__( - self, - *, - data: Optional[str] = None, - password: Optional[str] = None, - key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword data: Base 64 encoded certificate using the application/x-pkcs12 representation. - :paramtype data: str - :keyword password: Password for the Certificate. - :paramtype password: str - :keyword key_vault: KeyVault location details of the certificate. - :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - super().__init__(**kwargs) - self.data = data - self.password = password - self.key_vault = key_vault - - -class CertificateInformation(_serialization.Model): - """SSL certificate information. - - All required parameters must be populated in order to send to server. - - :ivar expiry: Expiration date of the certificate. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. - :vartype expiry: ~datetime.datetime - :ivar thumbprint: Thumbprint of the certificate. Required. - :vartype thumbprint: str - :ivar subject: Subject of the certificate. Required. - :vartype subject: str - """ - - _validation = { - "expiry": {"required": True}, - "thumbprint": {"required": True}, - "subject": {"required": True}, - } - - _attribute_map = { - "expiry": {"key": "expiry", "type": "iso-8601"}, - "thumbprint": {"key": "thumbprint", "type": "str"}, - "subject": {"key": "subject", "type": "str"}, - } - - def __init__(self, *, expiry: datetime.datetime, thumbprint: str, subject: str, **kwargs: Any) -> None: - """ - :keyword expiry: Expiration date of the certificate. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. - :paramtype expiry: ~datetime.datetime - :keyword thumbprint: Thumbprint of the certificate. Required. - :paramtype thumbprint: str - :keyword subject: Subject of the certificate. Required. - :paramtype subject: str - """ - super().__init__(**kwargs) - self.expiry = expiry - self.thumbprint = thumbprint - 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. - - :ivar client_secret: Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :vartype client_secret: str - """ - - _attribute_map = { - "client_secret": {"key": "clientSecret", "type": "str"}, - } - - def __init__(self, *, client_secret: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword client_secret: Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :paramtype client_secret: str - """ - super().__init__(**kwargs) - 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. - - All required parameters must be populated in order to send to server. - - :ivar source: Definitions about the connectivity check origin. Required. - :vartype source: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestSource - :ivar destination: The connectivity check operation destination. Required. - :vartype destination: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestDestination - :ivar preferred_ip_version: The IP version to be used. Only IPv4 is supported for now. "IPv4" - :vartype preferred_ip_version: str or ~azure.mgmt.apimanagement.models.PreferredIPVersion - :ivar protocol: The request's protocol. Specific protocol configuration can be available based - on this selection. The specified destination address must be coherent with this value. Known - values are: "TCP", "HTTP", and "HTTPS". - :vartype protocol: str or ~azure.mgmt.apimanagement.models.ConnectivityCheckProtocol - :ivar protocol_configuration: Protocol-specific configuration. - :vartype protocol_configuration: - ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration - """ - - _validation = { - "source": {"required": True}, - "destination": {"required": True}, - } - - _attribute_map = { - "source": {"key": "source", "type": "ConnectivityCheckRequestSource"}, - "destination": {"key": "destination", "type": "ConnectivityCheckRequestDestination"}, - "preferred_ip_version": {"key": "preferredIPVersion", "type": "str"}, - "protocol": {"key": "protocol", "type": "str"}, - "protocol_configuration": { - "key": "protocolConfiguration", - "type": "ConnectivityCheckRequestProtocolConfiguration", - }, - } - - def __init__( - self, - *, - source: "_models.ConnectivityCheckRequestSource", - destination: "_models.ConnectivityCheckRequestDestination", - preferred_ip_version: Optional[Union[str, "_models.PreferredIPVersion"]] = None, - protocol: Optional[Union[str, "_models.ConnectivityCheckProtocol"]] = None, - protocol_configuration: Optional["_models.ConnectivityCheckRequestProtocolConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword source: Definitions about the connectivity check origin. Required. - :paramtype source: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestSource - :keyword destination: The connectivity check operation destination. Required. - :paramtype destination: ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestDestination - :keyword preferred_ip_version: The IP version to be used. Only IPv4 is supported for now. - "IPv4" - :paramtype preferred_ip_version: str or ~azure.mgmt.apimanagement.models.PreferredIPVersion - :keyword protocol: The request's protocol. Specific protocol configuration can be available - based on this selection. The specified destination address must be coherent with this value. - Known values are: "TCP", "HTTP", and "HTTPS". - :paramtype protocol: str or ~azure.mgmt.apimanagement.models.ConnectivityCheckProtocol - :keyword protocol_configuration: Protocol-specific configuration. - :paramtype protocol_configuration: - ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfiguration - """ - super().__init__(**kwargs) - self.source = source - self.destination = destination - self.preferred_ip_version = preferred_ip_version - self.protocol = protocol - self.protocol_configuration = protocol_configuration - - -class ConnectivityCheckRequestDestination(_serialization.Model): - """The connectivity check operation destination. - - All required parameters must be populated in order to send to server. - - :ivar address: Destination address. Can either be an IP address or a FQDN. Required. - :vartype address: str - :ivar port: Destination port. Required. - :vartype port: int - """ - - _validation = { - "address": {"required": True}, - "port": {"required": True}, - } - - _attribute_map = { - "address": {"key": "address", "type": "str"}, - "port": {"key": "port", "type": "int"}, - } - - def __init__(self, *, address: str, port: int, **kwargs: Any) -> None: - """ - :keyword address: Destination address. Can either be an IP address or a FQDN. Required. - :paramtype address: str - :keyword port: Destination port. Required. - :paramtype port: int - """ - super().__init__(**kwargs) - self.address = address - self.port = port - - -class ConnectivityCheckRequestProtocolConfiguration(_serialization.Model): # pylint: disable=name-too-long - """Protocol-specific configuration. - - :ivar http_configuration: Configuration for HTTP or HTTPS requests. - :vartype http_configuration: - ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration - """ - - _attribute_map = { - "http_configuration": { - "key": "HTTPConfiguration", - "type": "ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration", - }, - } - - def __init__( - self, - *, - http_configuration: Optional["_models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration"] = None, - **kwargs: Any - ) -> None: - """ - :keyword http_configuration: Configuration for HTTP or HTTPS requests. - :paramtype http_configuration: - ~azure.mgmt.apimanagement.models.ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration - """ - super().__init__(**kwargs) - self.http_configuration = http_configuration - - -class ConnectivityCheckRequestProtocolConfigurationHTTPConfiguration( - _serialization.Model -): # pylint: disable=name-too-long - """Configuration for HTTP or HTTPS requests. - - :ivar method: The HTTP method to be used. Known values are: "GET" and "POST". - :vartype method: str or ~azure.mgmt.apimanagement.models.Method - :ivar valid_status_codes: List of HTTP status codes considered valid for the request response. - :vartype valid_status_codes: list[int] - :ivar headers: List of headers to be included in the request. - :vartype headers: list[~azure.mgmt.apimanagement.models.HTTPHeader] - """ - - _attribute_map = { - "method": {"key": "method", "type": "str"}, - "valid_status_codes": {"key": "validStatusCodes", "type": "[int]"}, - "headers": {"key": "headers", "type": "[HTTPHeader]"}, - } - - def __init__( - self, - *, - method: Optional[Union[str, "_models.Method"]] = None, - valid_status_codes: Optional[List[int]] = None, - headers: Optional[List["_models.HTTPHeader"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword method: The HTTP method to be used. Known values are: "GET" and "POST". - :paramtype method: str or ~azure.mgmt.apimanagement.models.Method - :keyword valid_status_codes: List of HTTP status codes considered valid for the request - response. - :paramtype valid_status_codes: list[int] - :keyword headers: List of headers to be included in the request. - :paramtype headers: list[~azure.mgmt.apimanagement.models.HTTPHeader] - """ - super().__init__(**kwargs) - self.method = method - self.valid_status_codes = valid_status_codes - self.headers = headers - - -class ConnectivityCheckRequestSource(_serialization.Model): - """Definitions about the connectivity check origin. - - All required parameters must be populated in order to send to server. - - :ivar region: The API Management service region from where to start the connectivity check - operation. Required. - :vartype region: str - :ivar instance: The particular VMSS instance from which to fire the request. - :vartype instance: int - """ - - _validation = { - "region": {"required": True}, - } - - _attribute_map = { - "region": {"key": "region", "type": "str"}, - "instance": {"key": "instance", "type": "int"}, - } - - def __init__(self, *, region: str, instance: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword region: The API Management service region from where to start the connectivity check - operation. Required. - :paramtype region: str - :keyword instance: The particular VMSS instance from which to fire the request. - :paramtype instance: int - """ - super().__init__(**kwargs) - self.region = region - self.instance = instance - - -class ConnectivityCheckResponse(_serialization.Model): - """Information on the connectivity status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar hops: List of hops between the source and the destination. - :vartype hops: list[~azure.mgmt.apimanagement.models.ConnectivityHop] - :ivar connection_status: The connection status. Known values are: "Unknown", "Connected", - "Disconnected", and "Degraded". - :vartype connection_status: str or ~azure.mgmt.apimanagement.models.ConnectionStatus - :ivar avg_latency_in_ms: Average latency in milliseconds. - :vartype avg_latency_in_ms: int - :ivar min_latency_in_ms: Minimum latency in milliseconds. - :vartype min_latency_in_ms: int - :ivar max_latency_in_ms: Maximum latency in milliseconds. - :vartype max_latency_in_ms: int - :ivar probes_sent: Total number of probes sent. - :vartype probes_sent: int - :ivar probes_failed: Number of failed probes. - :vartype probes_failed: int - """ - - _validation = { - "hops": {"readonly": True}, - "connection_status": {"readonly": True}, - "avg_latency_in_ms": {"readonly": True}, - "min_latency_in_ms": {"readonly": True}, - "max_latency_in_ms": {"readonly": True}, - "probes_sent": {"readonly": True}, - "probes_failed": {"readonly": True}, - } - - _attribute_map = { - "hops": {"key": "hops", "type": "[ConnectivityHop]"}, - "connection_status": {"key": "connectionStatus", "type": "str"}, - "avg_latency_in_ms": {"key": "avgLatencyInMs", "type": "int"}, - "min_latency_in_ms": {"key": "minLatencyInMs", "type": "int"}, - "max_latency_in_ms": {"key": "maxLatencyInMs", "type": "int"}, - "probes_sent": {"key": "probesSent", "type": "int"}, - "probes_failed": {"key": "probesFailed", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.hops = None - self.connection_status = None - self.avg_latency_in_ms = None - self.min_latency_in_ms = None - self.max_latency_in_ms = None - self.probes_sent = None - self.probes_failed = None - - -class ConnectivityHop(_serialization.Model): - """Information about a hop between the source and the destination. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the hop. - :vartype type: str - :ivar id: The ID of the hop. - :vartype id: str - :ivar address: The IP address of the hop. - :vartype address: str - :ivar resource_id: The ID of the resource corresponding to this hop. - :vartype resource_id: str - :ivar next_hop_ids: List of next hop identifiers. - :vartype next_hop_ids: list[str] - :ivar issues: List of issues. - :vartype issues: list[~azure.mgmt.apimanagement.models.ConnectivityIssue] - """ - - _validation = { - "type": {"readonly": True}, - "id": {"readonly": True}, - "address": {"readonly": True}, - "resource_id": {"readonly": True}, - "next_hop_ids": {"readonly": True}, - "issues": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "address": {"key": "address", "type": "str"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "next_hop_ids": {"key": "nextHopIds", "type": "[str]"}, - "issues": {"key": "issues", "type": "[ConnectivityIssue]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.id = None - self.address = None - self.resource_id = None - self.next_hop_ids = None - self.issues = None - - -class ConnectivityIssue(_serialization.Model): - """Information about an issue encountered in the process of checking for connectivity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar origin: The origin of the issue. Known values are: "Local", "Inbound", and "Outbound". - :vartype origin: str or ~azure.mgmt.apimanagement.models.Origin - :ivar severity: The severity of the issue. Known values are: "Error" and "Warning". - :vartype severity: str or ~azure.mgmt.apimanagement.models.Severity - :ivar type: The type of issue. Known values are: "Unknown", "AgentStopped", "GuestFirewall", - "DnsResolution", "SocketBind", "NetworkSecurityRule", "UserDefinedRoute", "PortThrottled", and - "Platform". - :vartype type: str or ~azure.mgmt.apimanagement.models.IssueType - :ivar context: Provides additional context on the issue. - :vartype context: list[dict[str, str]] - """ - - _validation = { - "origin": {"readonly": True}, - "severity": {"readonly": True}, - "type": {"readonly": True}, - "context": {"readonly": True}, - } - - _attribute_map = { - "origin": {"key": "origin", "type": "str"}, - "severity": {"key": "severity", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "context": {"key": "context", "type": "[{str}]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.origin = None - self.severity = None - self.type = None - self.context = None - - -class ConnectivityStatusContract(_serialization.Model): - """Details about connectivity to a resource. - - All required parameters must be populated in order to send to server. - - :ivar name: The hostname of the resource which the service depends on. This can be the - database, storage or any other azure resource on which the service depends upon. Required. - :vartype name: str - :ivar status: Resource Connectivity Status Type identifier. Required. Known values are: - "initializing", "success", and "failure". - :vartype status: str or ~azure.mgmt.apimanagement.models.ConnectivityStatusType - :ivar error: Error details of the connectivity to the resource. - :vartype error: str - :ivar last_updated: The date when the resource connectivity status was last updated. This - status should be updated every 15 minutes. If this status has not been updated, then it means - that the service has lost network connectivity to the resource, from inside the Virtual - Network.The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the - ISO 8601 standard. Required. - :vartype last_updated: ~datetime.datetime - :ivar last_status_change: The date when the resource connectivity status last Changed from - success to failure or vice-versa. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. - :vartype last_status_change: ~datetime.datetime - :ivar resource_type: Resource Type. Required. - :vartype resource_type: str - :ivar is_optional: Whether this is optional. Required. - :vartype is_optional: bool - """ - - _validation = { - "name": {"required": True, "min_length": 1}, - "status": {"required": True}, - "last_updated": {"required": True}, - "last_status_change": {"required": True}, - "resource_type": {"required": True}, - "is_optional": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "error": {"key": "error", "type": "str"}, - "last_updated": {"key": "lastUpdated", "type": "iso-8601"}, - "last_status_change": {"key": "lastStatusChange", "type": "iso-8601"}, - "resource_type": {"key": "resourceType", "type": "str"}, - "is_optional": {"key": "isOptional", "type": "bool"}, - } - - def __init__( - self, - *, - name: str, - status: Union[str, "_models.ConnectivityStatusType"], - last_updated: datetime.datetime, - last_status_change: datetime.datetime, - resource_type: str, - is_optional: bool, - error: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The hostname of the resource which the service depends on. This can be the - database, storage or any other azure resource on which the service depends upon. Required. - :paramtype name: str - :keyword status: Resource Connectivity Status Type identifier. Required. Known values are: - "initializing", "success", and "failure". - :paramtype status: str or ~azure.mgmt.apimanagement.models.ConnectivityStatusType - :keyword error: Error details of the connectivity to the resource. - :paramtype error: str - :keyword last_updated: The date when the resource connectivity status was last updated. This - status should be updated every 15 minutes. If this status has not been updated, then it means - that the service has lost network connectivity to the resource, from inside the Virtual - Network.The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the - ISO 8601 standard. Required. - :paramtype last_updated: ~datetime.datetime - :keyword last_status_change: The date when the resource connectivity status last Changed from - success to failure or vice-versa. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. - :paramtype last_status_change: ~datetime.datetime - :keyword resource_type: Resource Type. Required. - :paramtype resource_type: str - :keyword is_optional: Whether this is optional. Required. - :paramtype is_optional: bool - """ - super().__init__(**kwargs) - self.name = name - self.status = status - self.error = error - self.last_updated = last_updated - self.last_status_change = last_status_change - self.resource_type = resource_type - self.is_optional = is_optional - - -class ContentItemCollection(_serialization.Model): - """Paged list of content items. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of content items. - :vartype value: list[~azure.mgmt.apimanagement.models.ContentItemContract] - :ivar next_link: Next page link, if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ContentItemContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class ContentItemContract(ProxyResource): - """Content type 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 properties: Properties of the content item. - :vartype properties: dict[str, any] - """ - - _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"}, - "properties": {"key": "properties", "type": "{object}"}, - } - - def __init__(self, *, properties: Optional[Dict[str, Any]] = None, **kwargs: Any) -> None: - """ - :keyword properties: Properties of the content item. - :paramtype properties: dict[str, any] - """ - super().__init__(**kwargs) - self.properties = properties - - -class ContentTypeCollection(_serialization.Model): - """Paged list of content types. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of content types. - :vartype value: list[~azure.mgmt.apimanagement.models.ContentTypeContract] - :ivar next_link: Next page link, if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ContentTypeContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class ContentTypeContract(ProxyResource): - """Content type 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 id_properties_id: Content type identifier. - :vartype id_properties_id: str - :ivar name_properties_name: Content type name. Must be 1 to 250 characters long. - :vartype name_properties_name: str - :ivar description: Content type description. - :vartype description: str - :ivar schema: Content type schema. - :vartype schema: JSON - :ivar version: Content type version. - :vartype version: 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"}, - "id_properties_id": {"key": "properties.id", "type": "str"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "schema": {"key": "properties.schema", "type": "object"}, - "version": {"key": "properties.version", "type": "str"}, - } - - def __init__( - self, - *, - id_properties_id: Optional[str] = None, - name_properties_name: Optional[str] = None, - description: Optional[str] = None, - schema: Optional[JSON] = None, - version: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id_properties_id: Content type identifier. - :paramtype id_properties_id: str - :keyword name_properties_name: Content type name. Must be 1 to 250 characters long. - :paramtype name_properties_name: str - :keyword description: Content type description. - :paramtype description: str - :keyword schema: Content type schema. - :paramtype schema: JSON - :keyword version: Content type version. - :paramtype version: str - """ - super().__init__(**kwargs) - self.id_properties_id = id_properties_id - self.name_properties_name = name_properties_name - self.description = description - self.schema = schema - self.version = version - - -class DataMasking(_serialization.Model): - """DataMasking. - - :ivar query_params: Masking settings for Url query parameters. - :vartype query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] - :ivar headers: Masking settings for headers. - :vartype headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] - """ - - _attribute_map = { - "query_params": {"key": "queryParams", "type": "[DataMaskingEntity]"}, - "headers": {"key": "headers", "type": "[DataMaskingEntity]"}, - } - - def __init__( - self, - *, - query_params: Optional[List["_models.DataMaskingEntity"]] = None, - headers: Optional[List["_models.DataMaskingEntity"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword query_params: Masking settings for Url query parameters. - :paramtype query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] - :keyword headers: Masking settings for headers. - :paramtype headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] - """ - super().__init__(**kwargs) - self.query_params = query_params - self.headers = headers - - -class DataMaskingEntity(_serialization.Model): - """DataMaskingEntity. - - :ivar value: The name of an entity to mask (e.g. a name of a header or a query parameter). - :vartype value: str - :ivar mode: Data masking mode. Known values are: "Mask" and "Hide". - :vartype mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - "mode": {"key": "mode", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[str] = None, - mode: Optional[Union[str, "_models.DataMaskingMode"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The name of an entity to mask (e.g. a name of a header or a query parameter). - :paramtype value: str - :keyword mode: Data masking mode. Known values are: "Mask" and "Hide". - :paramtype mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode - """ - super().__init__(**kwargs) - self.value = value - self.mode = mode - - -class DeletedServiceContract(ProxyResource): - """Deleted API Management Service information. - - 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 location: API Management Service Master Location. - :vartype location: str - :ivar service_id: Fully-qualified API Management Service Resource ID. - :vartype service_id: str - :ivar scheduled_purge_date: UTC Date and Time when the service will be automatically purged. - The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 - standard. - :vartype scheduled_purge_date: ~datetime.datetime - :ivar deletion_date: UTC Timestamp when the service was soft-deleted. The date conforms to the - following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :vartype deletion_date: ~datetime.datetime - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "service_id": {"key": "properties.serviceId", "type": "str"}, - "scheduled_purge_date": {"key": "properties.scheduledPurgeDate", "type": "iso-8601"}, - "deletion_date": {"key": "properties.deletionDate", "type": "iso-8601"}, - } - - def __init__( - self, - *, - service_id: Optional[str] = None, - scheduled_purge_date: Optional[datetime.datetime] = None, - deletion_date: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword service_id: Fully-qualified API Management Service Resource ID. - :paramtype service_id: str - :keyword scheduled_purge_date: UTC Date and Time when the service will be automatically purged. - The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 - standard. - :paramtype scheduled_purge_date: ~datetime.datetime - :keyword deletion_date: UTC Timestamp when the service was soft-deleted. The date conforms to - the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. - :paramtype deletion_date: ~datetime.datetime - """ - super().__init__(**kwargs) - self.location = None - self.service_id = service_id - self.scheduled_purge_date = scheduled_purge_date - self.deletion_date = deletion_date - - -class DeletedServicesCollection(_serialization.Model): - """Paged deleted API Management Services List Representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.DeletedServiceContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DeletedServiceContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class DeployConfigurationParameters(_serialization.Model): - """Deploy Tenant Configuration Contract. - - :ivar branch: The name of the Git branch from which the configuration is to be deployed to the - configuration database. - :vartype branch: str - :ivar force: The value enforcing deleting subscriptions to products that are deleted in this - update. - :vartype force: bool - """ - - _attribute_map = { - "branch": {"key": "properties.branch", "type": "str"}, - "force": {"key": "properties.force", "type": "bool"}, - } - - def __init__(self, *, branch: Optional[str] = None, force: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword branch: The name of the Git branch from which the configuration is to be deployed to - the configuration database. - :paramtype branch: str - :keyword force: The value enforcing deleting subscriptions to products that are deleted in this - update. - :paramtype force: bool - """ - super().__init__(**kwargs) - self.branch = branch - self.force = force - - -class DiagnosticCollection(_serialization.Model): - """Paged Diagnostic list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] - :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": "[DiagnosticContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.DiagnosticContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] - :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 DiagnosticContract(ProxyResource): - """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 DiagnosticUpdateContract(ProxyResource): - """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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.DocumentationContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[DocumentationContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class DocumentationContract(ProxyResource): - """Markdown documentation 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 title: documentation title. - :vartype title: str - :ivar content: Markdown documentation content. - :vartype content: 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"}, - "title": {"key": "properties.title", "type": "str"}, - "content": {"key": "properties.content", "type": "str"}, - } - - def __init__(self, *, title: Optional[str] = None, content: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword title: documentation title. - :paramtype title: str - :keyword content: Markdown documentation content. - :paramtype content: str - """ - super().__init__(**kwargs) - self.title = title - self.content = content - - -class DocumentationUpdateContract(_serialization.Model): - """Documentation update contract details. - - :ivar title: documentation title. - :vartype title: str - :ivar content: Markdown documentation content. - :vartype content: str - """ - - _attribute_map = { - "title": {"key": "properties.title", "type": "str"}, - "content": {"key": "properties.content", "type": "str"}, - } - - def __init__(self, *, title: Optional[str] = None, content: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword title: documentation title. - :paramtype title: str - :keyword content: Markdown documentation content. - :paramtype content: str - """ - super().__init__(**kwargs) - self.title = title - self.content = content - - -class EmailTemplateCollection(_serialization.Model): - """Paged email template list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] - :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": "[EmailTemplateContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.EmailTemplateContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] - :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 EmailTemplateContract(ProxyResource): - """Email Template 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 subject: Subject of the Template. - :vartype subject: str - :ivar body: Email Template Body. This should be a valid XDocument. - :vartype body: str - :ivar title: Title of the Template. - :vartype title: str - :ivar description: Description of the Email Template. - :vartype description: str - :ivar is_default: Whether the template is the default template provided by API Management or - has been edited. - :vartype is_default: bool - :ivar parameters: Email Template Parameter values. - :vartype parameters: - list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "subject": {"max_length": 1000, "min_length": 1}, - "body": {"min_length": 1}, - "is_default": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "subject": {"key": "properties.subject", "type": "str"}, - "body": {"key": "properties.body", "type": "str"}, - "title": {"key": "properties.title", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "is_default": {"key": "properties.isDefault", "type": "bool"}, - "parameters": {"key": "properties.parameters", "type": "[EmailTemplateParametersContractProperties]"}, - } - - def __init__( - self, - *, - subject: Optional[str] = None, - body: Optional[str] = None, - title: Optional[str] = None, - description: Optional[str] = None, - parameters: Optional[List["_models.EmailTemplateParametersContractProperties"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword subject: Subject of the Template. - :paramtype subject: str - :keyword body: Email Template Body. This should be a valid XDocument. - :paramtype body: str - :keyword title: Title of the Template. - :paramtype title: str - :keyword description: Description of the Email Template. - :paramtype description: str - :keyword parameters: Email Template Parameter values. - :paramtype parameters: - list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] - """ - super().__init__(**kwargs) - self.subject = subject - self.body = body - self.title = title - self.description = description - self.is_default = None - self.parameters = parameters - - -class EmailTemplateParametersContractProperties(_serialization.Model): # pylint: disable=name-too-long - """Email Template Parameter contract. - - :ivar name: Template parameter name. - :vartype name: str - :ivar title: Template parameter title. - :vartype title: str - :ivar description: Template parameter description. - :vartype description: str - """ - - _validation = { - "name": {"max_length": 256, "min_length": 1, "pattern": r"^[A-Za-z0-9-._]+$"}, - "title": {"max_length": 4096, "min_length": 1}, - "description": {"max_length": 256, "min_length": 1, "pattern": r"^[A-Za-z0-9-._]+$"}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - title: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Template parameter name. - :paramtype name: str - :keyword title: Template parameter title. - :paramtype title: str - :keyword description: Template parameter description. - :paramtype description: str - """ - super().__init__(**kwargs) - self.name = name - self.title = title - self.description = description - - -class EmailTemplateUpdateParameters(_serialization.Model): - """Email Template update Parameters. - - :ivar subject: Subject of the Template. - :vartype subject: str - :ivar title: Title of the Template. - :vartype title: str - :ivar description: Description of the Email Template. - :vartype description: str - :ivar body: Email Template Body. This should be a valid XDocument. - :vartype body: str - :ivar parameters: Email Template Parameter values. - :vartype parameters: - list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] - """ - - _validation = { - "subject": {"max_length": 1000, "min_length": 1}, - "body": {"min_length": 1}, - } - - _attribute_map = { - "subject": {"key": "properties.subject", "type": "str"}, - "title": {"key": "properties.title", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "body": {"key": "properties.body", "type": "str"}, - "parameters": {"key": "properties.parameters", "type": "[EmailTemplateParametersContractProperties]"}, - } - - def __init__( - self, - *, - subject: Optional[str] = None, - title: Optional[str] = None, - description: Optional[str] = None, - body: Optional[str] = None, - parameters: Optional[List["_models.EmailTemplateParametersContractProperties"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword subject: Subject of the Template. - :paramtype subject: str - :keyword title: Title of the Template. - :paramtype title: str - :keyword description: Description of the Email Template. - :paramtype description: str - :keyword body: Email Template Body. This should be a valid XDocument. - :paramtype body: str - :keyword parameters: Email Template Parameter values. - :paramtype parameters: - list[~azure.mgmt.apimanagement.models.EmailTemplateParametersContractProperties] - """ - super().__init__(**kwargs) - self.subject = subject - self.title = title - self.description = description - self.body = body - self.parameters = parameters - - -class EndpointDependency(_serialization.Model): - """A domain name that a service is reached at. - - :ivar domain_name: The domain name of the dependency. - :vartype domain_name: str - :ivar endpoint_details: The Ports used when connecting to DomainName. - :vartype endpoint_details: list[~azure.mgmt.apimanagement.models.EndpointDetail] - """ - - _attribute_map = { - "domain_name": {"key": "domainName", "type": "str"}, - "endpoint_details": {"key": "endpointDetails", "type": "[EndpointDetail]"}, - } - - def __init__( - self, - *, - domain_name: Optional[str] = None, - endpoint_details: Optional[List["_models.EndpointDetail"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword domain_name: The domain name of the dependency. - :paramtype domain_name: str - :keyword endpoint_details: The Ports used when connecting to DomainName. - :paramtype endpoint_details: list[~azure.mgmt.apimanagement.models.EndpointDetail] - """ - super().__init__(**kwargs) - self.domain_name = domain_name - self.endpoint_details = endpoint_details - - -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. - - 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 = { - "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, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorFieldContract(_serialization.Model): - """Error Field contract. - - :ivar code: Property level error code. - :vartype code: str - :ivar message: Human-readable representation of property-level error. - :vartype message: str - :ivar target: Property name. - :vartype target: str - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - } - - def __init__( - self, *, code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword code: Property level error code. - :paramtype code: str - :keyword message: Human-readable representation of property-level error. - :paramtype message: str - :keyword target: Property name. - :paramtype target: str - """ - super().__init__(**kwargs) - self.code = code - self.message = message - self.target = target - - -class ErrorResponse(_serialization.Model): - """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 error: The error object. - :vartype error: ~azure.mgmt.apimanagement.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.apimanagement.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorResponseBody(_serialization.Model): - """Error Body contract. - - :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] - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "details": {"key": "details", "type": "[ErrorFieldContract]"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - details: Optional[List["_models.ErrorFieldContract"]] = 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] - """ - super().__init__(**kwargs) - self.code = code - self.message = message - 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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GatewayCertificateAuthorityContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class GatewayCertificateAuthorityContract(ProxyResource): - """Gateway certificate authority 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 is_trusted: Determines whether certificate authority is trusted. - :vartype is_trusted: 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"}, - "is_trusted": {"key": "properties.isTrusted", "type": "bool"}, - } - - def __init__(self, *, is_trusted: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_trusted: Determines whether certificate authority is trusted. - :paramtype is_trusted: bool - """ - super().__init__(**kwargs) - self.is_trusted = is_trusted - - -class GatewayCollection(_serialization.Model): - """Paged Gateway list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.GatewayContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GatewayContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - 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. - - 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 location_data: Gateway location. - :vartype location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract - :ivar description: Gateway description. - :vartype description: str - """ - - _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"}, - "location_data": {"key": "properties.locationData", "type": "ResourceLocationDataContract"}, - "description": {"key": "properties.description", "type": "str"}, - } - - def __init__( - self, - *, - location_data: Optional["_models.ResourceLocationDataContract"] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword location_data: Gateway location. - :paramtype location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract - :keyword description: Gateway description. - :paramtype description: str - """ - super().__init__(**kwargs) - self.location_data = location_data - 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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GatewayHostnameConfigurationContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class GatewayHostnameConfigurationContract(ProxyResource): - """Gateway hostname configuration 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 hostname: Hostname value. Supports valid domain name, partial or full wildcard. - :vartype hostname: str - :ivar certificate_id: Identifier of Certificate entity that will be used for TLS connection - establishment. - :vartype certificate_id: str - :ivar negotiate_client_certificate: Determines whether gateway requests client certificate. - :vartype negotiate_client_certificate: bool - :ivar tls10_enabled: Specifies if TLS 1.0 is supported. - :vartype tls10_enabled: bool - :ivar tls11_enabled: Specifies if TLS 1.1 is supported. - :vartype tls11_enabled: bool - :ivar http2_enabled: Specifies if HTTP/2.0 is supported. - :vartype http2_enabled: 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"}, - "hostname": {"key": "properties.hostname", "type": "str"}, - "certificate_id": {"key": "properties.certificateId", "type": "str"}, - "negotiate_client_certificate": {"key": "properties.negotiateClientCertificate", "type": "bool"}, - "tls10_enabled": {"key": "properties.tls10Enabled", "type": "bool"}, - "tls11_enabled": {"key": "properties.tls11Enabled", "type": "bool"}, - "http2_enabled": {"key": "properties.http2Enabled", "type": "bool"}, - } - - def __init__( - self, - *, - hostname: Optional[str] = None, - certificate_id: Optional[str] = None, - negotiate_client_certificate: Optional[bool] = None, - tls10_enabled: Optional[bool] = None, - tls11_enabled: Optional[bool] = None, - http2_enabled: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword hostname: Hostname value. Supports valid domain name, partial or full wildcard. - :paramtype hostname: str - :keyword certificate_id: Identifier of Certificate entity that will be used for TLS connection - establishment. - :paramtype certificate_id: str - :keyword negotiate_client_certificate: Determines whether gateway requests client certificate. - :paramtype negotiate_client_certificate: bool - :keyword tls10_enabled: Specifies if TLS 1.0 is supported. - :paramtype tls10_enabled: bool - :keyword tls11_enabled: Specifies if TLS 1.1 is supported. - :paramtype tls11_enabled: bool - :keyword http2_enabled: Specifies if HTTP/2.0 is supported. - :paramtype http2_enabled: bool - """ - super().__init__(**kwargs) - self.hostname = hostname - self.certificate_id = certificate_id - self.negotiate_client_certificate = negotiate_client_certificate - self.tls10_enabled = tls10_enabled - self.tls11_enabled = tls11_enabled - self.http2_enabled = http2_enabled - - -class GatewayKeyRegenerationRequestContract(_serialization.Model): - """Gateway key regeneration request contract properties. - - All required parameters must be populated in order to send to server. - - :ivar key_type: The Key being regenerated. Required. Known values are: "primary" and - "secondary". - :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType - """ - - _validation = { - "key_type": {"required": True}, - } - - _attribute_map = { - "key_type": {"key": "keyType", "type": "str"}, - } - - def __init__(self, *, key_type: Union[str, "_models.KeyType"], **kwargs: Any) -> None: - """ - :keyword key_type: The Key being regenerated. Required. Known values are: "primary" and - "secondary". - :paramtype key_type: str or ~azure.mgmt.apimanagement.models.KeyType - """ - super().__init__(**kwargs) - self.key_type = key_type - - -class GatewayKeysContract(_serialization.Model): - """Gateway authentication keys. - - :ivar primary: Primary gateway key. - :vartype primary: str - :ivar secondary: Secondary gateway key. - :vartype secondary: str - """ - - _attribute_map = { - "primary": {"key": "primary", "type": "str"}, - "secondary": {"key": "secondary", "type": "str"}, - } - - def __init__(self, *, primary: Optional[str] = None, secondary: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword primary: Primary gateway key. - :paramtype primary: str - :keyword secondary: Secondary gateway key. - :paramtype secondary: str - """ - super().__init__(**kwargs) - 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.ApiGatewaySkuType - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[Union[str, "_models.ApiGatewaySkuType"]] = 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.ApiGatewaySkuType - """ - 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): - """Gateway access token. - - :ivar value: Shared Access Authentication token value for the Gateway. - :vartype value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: Shared Access Authentication token value for the Gateway. - :paramtype value: str - """ - super().__init__(**kwargs) - self.value = value - - -class GatewayTokenRequestContract(_serialization.Model): - """Gateway token request contract properties. - - All required parameters must be populated in order to send to server. - - :ivar key_type: The Key to be used to generate gateway token. Required. Known values are: - "primary" and "secondary". - :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :ivar expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The - date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 - standard. Required. - :vartype expiry: ~datetime.datetime - """ - - _validation = { - "key_type": {"required": True}, - "expiry": {"required": True}, - } - - _attribute_map = { - "key_type": {"key": "keyType", "type": "str"}, - "expiry": {"key": "expiry", "type": "iso-8601"}, - } - - def __init__(self, *, key_type: Union[str, "_models.KeyType"], expiry: datetime.datetime, **kwargs: Any) -> None: - """ - :keyword key_type: The Key to be used to generate gateway token. Required. Known values are: - "primary" and "secondary". - :paramtype key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :keyword expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The - date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 - standard. Required. - :paramtype expiry: ~datetime.datetime - """ - super().__init__(**kwargs) - self.key_type = key_type - self.expiry = expiry - - -class GenerateSsoUrlResult(_serialization.Model): - """Generate SSO Url operations response details. - - :ivar value: Redirect Url containing the SSO URL value. - :vartype value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: Redirect Url containing the SSO URL value. - :paramtype value: str - """ - super().__init__(**kwargs) - self.value = value - - -class GlobalSchemaCollection(_serialization.Model): - """The response of the list schema operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Global Schema Contract value. - :vartype value: list[~azure.mgmt.apimanagement.models.GlobalSchemaContract] - :ivar count: Total record count number. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[GlobalSchemaContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class GlobalSchemaContract(ProxyResource): - """Global Schema 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 schema_type: Schema Type. Immutable. Known values are: "xml" and "json". - :vartype schema_type: str or ~azure.mgmt.apimanagement.models.SchemaType - :ivar description: Free-form schema entity description. - :vartype description: str - :ivar value: Json-encoded string for non json-based schema. - :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 = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "schema_type": {"key": "properties.schemaType", "type": "str"}, - "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__( - self, - *, - schema_type: Optional[Union[str, "_models.SchemaType"]] = None, - description: Optional[str] = None, - value: Optional[Any] = None, - document: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword schema_type: Schema Type. Immutable. Known values are: "xml" and "json". - :paramtype schema_type: str or ~azure.mgmt.apimanagement.models.SchemaType - :keyword description: Free-form schema entity description. - :paramtype description: str - :keyword value: Json-encoded string for non json-based schema. - :paramtype value: any - :keyword document: Global Schema document object for json-based schema formats(e.g. json - schema). - :paramtype document: JSON - """ - super().__init__(**kwargs) - self.schema_type = schema_type - self.description = description - self.value = value - self.document = document - self.provisioning_state = None - - -class GroupCollection(_serialization.Model): - """Paged Group list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.GroupContract] - :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": "[GroupContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.GroupContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.GroupContract] - :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 GroupContract(ProxyResource): - """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 display_name: Group name. - :vartype display_name: str - :ivar description: Group description. Can contain HTML formatting tags. - :vartype description: str - :ivar built_in: true if the group is one of the three system groups (Administrators, - Developers, or Guests); otherwise false. - :vartype built_in: bool - :ivar type_properties_type: Group type. Known values are: "custom", "system", and "external". - :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. - :vartype external_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"max_length": 300, "min_length": 1}, - "description": {"max_length": 1000}, - "built_in": {"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"}, - "built_in": {"key": "properties.builtIn", "type": "bool"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "external_id": {"key": "properties.externalId", "type": "str"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - type_properties_type: Optional[Union[str, "_models.GroupType"]] = None, - external_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: Group name. - :paramtype display_name: str - :keyword description: Group description. Can contain HTML formatting tags. - :paramtype description: str - :keyword type_properties_type: Group type. Known values are: "custom", "system", and - "external". - :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. - :paramtype external_id: str - """ - super().__init__(**kwargs) - self.display_name = display_name - self.description = description - self.built_in = None - self.type_properties_type = type_properties_type - self.external_id = external_id - - -class GroupContractProperties(_serialization.Model): - """Group 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 display_name: Group name. Required. - :vartype display_name: str - :ivar description: Group description. Can contain HTML formatting tags. - :vartype description: str - :ivar built_in: true if the group is one of the three system groups (Administrators, - Developers, or Guests); otherwise false. - :vartype built_in: bool - :ivar type: Group type. Known values are: "custom", "system", and "external". - :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. - :vartype external_id: str - """ - - _validation = { - "display_name": {"required": True, "max_length": 300, "min_length": 1}, - "description": {"max_length": 1000}, - "built_in": {"readonly": True}, - } - - _attribute_map = { - "display_name": {"key": "displayName", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "built_in": {"key": "builtIn", "type": "bool"}, - "type": {"key": "type", "type": "str"}, - "external_id": {"key": "externalId", "type": "str"}, - } - - def __init__( - self, - *, - display_name: str, - description: Optional[str] = None, - type: Optional[Union[str, "_models.GroupType"]] = None, - external_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: Group name. Required. - :paramtype display_name: str - :keyword description: Group description. Can contain HTML formatting tags. - :paramtype description: str - :keyword type: Group type. Known values are: "custom", "system", and "external". - :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. - :paramtype external_id: str - """ - super().__init__(**kwargs) - self.display_name = display_name - self.description = description - self.built_in = None - self.type = type - self.external_id = external_id - - -class GroupCreateParameters(_serialization.Model): - """Parameters supplied to the Create Group operation. - - :ivar display_name: Group name. - :vartype display_name: str - :ivar description: Group description. - :vartype description: str - :ivar type: Group type. Known values are: "custom", "system", and "external". - :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. - :vartype external_id: str - """ - - _validation = { - "display_name": {"max_length": 300, "min_length": 1}, - } - - _attribute_map = { - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "external_id": {"key": "properties.externalId", "type": "str"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - type: Optional[Union[str, "_models.GroupType"]] = None, - external_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: Group name. - :paramtype display_name: str - :keyword description: Group description. - :paramtype description: str - :keyword type: Group type. Known values are: "custom", "system", and "external". - :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. - :paramtype external_id: str - """ - super().__init__(**kwargs) - self.display_name = display_name - self.description = description - self.type = type - self.external_id = external_id - - -class GroupUpdateParameters(_serialization.Model): - """Parameters supplied to the Update Group operation. - - :ivar display_name: Group name. - :vartype display_name: str - :ivar description: Group description. - :vartype description: str - :ivar type: Group type. Known values are: "custom", "system", and "external". - :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. - :vartype external_id: str - """ - - _validation = { - "display_name": {"max_length": 300, "min_length": 1}, - } - - _attribute_map = { - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "type": {"key": "properties.type", "type": "str"}, - "external_id": {"key": "properties.externalId", "type": "str"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - type: Optional[Union[str, "_models.GroupType"]] = None, - external_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: Group name. - :paramtype display_name: str - :keyword description: Group description. - :paramtype description: str - :keyword type: Group type. Known values are: "custom", "system", and "external". - :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. - :paramtype external_id: str - """ - super().__init__(**kwargs) - self.display_name = display_name - self.description = description - self.type = type - self.external_id = external_id - - -class HostnameConfiguration(_serialization.Model): - """Custom hostname configuration. - - All required parameters must be populated in order to send to server. - - :ivar type: Hostname type. Required. Known values are: "Proxy", "Portal", "Management", "Scm", - "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 - :ivar key_vault_id: Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url - containing version is provided, auto-update of ssl certificate will not work. This requires Api - Management service to be configured with aka.ms/apimmsi. The secret should be of type - *application/x-pkcs12*. - :vartype key_vault_id: str - :ivar identity_client_id: System or User Assigned Managed identity clientId as generated by - Azure AD, which has GET access to the keyVault containing the SSL certificate. - :vartype identity_client_id: str - :ivar encoded_certificate: Base64 Encoded certificate. - :vartype encoded_certificate: str - :ivar certificate_password: Certificate Password. - :vartype certificate_password: str - :ivar default_ssl_binding: Specify true to setup the certificate associated with this Hostname - as the Default SSL Certificate. If a client does not send the SNI header, then this will be the - certificate that will be challenged. The property is useful if a service has multiple custom - hostname enabled and it needs to decide on the default ssl certificate. The setting only - applied to gateway Hostname Type. - :vartype default_ssl_binding: bool - :ivar negotiate_client_certificate: Specify true to always negotiate client certificate on the - hostname. Default Value is false. - :vartype negotiate_client_certificate: bool - :ivar certificate: Certificate information. - :vartype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation - :ivar certificate_source: Certificate Source. Known values are: "Managed", "KeyVault", - "Custom", and "BuiltIn". - :vartype certificate_source: str or ~azure.mgmt.apimanagement.models.CertificateSource - :ivar certificate_status: Certificate Status. Known values are: "Completed", "Failed", and - "InProgress". - :vartype certificate_status: str or ~azure.mgmt.apimanagement.models.CertificateStatus - """ - - _validation = { - "type": {"required": True}, - "host_name": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "host_name": {"key": "hostName", "type": "str"}, - "key_vault_id": {"key": "keyVaultId", "type": "str"}, - "identity_client_id": {"key": "identityClientId", "type": "str"}, - "encoded_certificate": {"key": "encodedCertificate", "type": "str"}, - "certificate_password": {"key": "certificatePassword", "type": "str"}, - "default_ssl_binding": {"key": "defaultSslBinding", "type": "bool"}, - "negotiate_client_certificate": {"key": "negotiateClientCertificate", "type": "bool"}, - "certificate": {"key": "certificate", "type": "CertificateInformation"}, - "certificate_source": {"key": "certificateSource", "type": "str"}, - "certificate_status": {"key": "certificateStatus", "type": "str"}, - } - - def __init__( - self, - *, - type: Union[str, "_models.HostnameType"], - host_name: str, - key_vault_id: Optional[str] = None, - identity_client_id: Optional[str] = None, - encoded_certificate: Optional[str] = None, - certificate_password: Optional[str] = None, - default_ssl_binding: bool = False, - negotiate_client_certificate: bool = False, - certificate: Optional["_models.CertificateInformation"] = None, - certificate_source: Optional[Union[str, "_models.CertificateSource"]] = None, - certificate_status: Optional[Union[str, "_models.CertificateStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Hostname type. Required. Known values are: "Proxy", "Portal", "Management", - "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 - :keyword key_vault_id: Url to the KeyVault Secret containing the Ssl Certificate. If absolute - Url containing version is provided, auto-update of ssl certificate will not work. This requires - Api Management service to be configured with aka.ms/apimmsi. The secret should be of type - *application/x-pkcs12*. - :paramtype key_vault_id: str - :keyword identity_client_id: System or User Assigned Managed identity clientId as generated by - Azure AD, which has GET access to the keyVault containing the SSL certificate. - :paramtype identity_client_id: str - :keyword encoded_certificate: Base64 Encoded certificate. - :paramtype encoded_certificate: str - :keyword certificate_password: Certificate Password. - :paramtype certificate_password: str - :keyword default_ssl_binding: Specify true to setup the certificate associated with this - Hostname as the Default SSL Certificate. If a client does not send the SNI header, then this - will be the certificate that will be challenged. The property is useful if a service has - multiple custom hostname enabled and it needs to decide on the default ssl certificate. The - setting only applied to gateway Hostname Type. - :paramtype default_ssl_binding: bool - :keyword negotiate_client_certificate: Specify true to always negotiate client certificate on - the hostname. Default Value is false. - :paramtype negotiate_client_certificate: bool - :keyword certificate: Certificate information. - :paramtype certificate: ~azure.mgmt.apimanagement.models.CertificateInformation - :keyword certificate_source: Certificate Source. Known values are: "Managed", "KeyVault", - "Custom", and "BuiltIn". - :paramtype certificate_source: str or ~azure.mgmt.apimanagement.models.CertificateSource - :keyword certificate_status: Certificate Status. Known values are: "Completed", "Failed", and - "InProgress". - :paramtype certificate_status: str or ~azure.mgmt.apimanagement.models.CertificateStatus - """ - super().__init__(**kwargs) - self.type = type - self.host_name = host_name - self.key_vault_id = key_vault_id - self.identity_client_id = identity_client_id - self.encoded_certificate = encoded_certificate - self.certificate_password = certificate_password - self.default_ssl_binding = default_ssl_binding - self.negotiate_client_certificate = negotiate_client_certificate - self.certificate = certificate - self.certificate_source = certificate_source - self.certificate_status = certificate_status - - -class HTTPHeader(_serialization.Model): - """HTTP header and it's value. - - All required parameters must be populated in order to send to server. - - :ivar name: Header name. Required. - :vartype name: str - :ivar value: Header value. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: Header name. Required. - :paramtype name: str - :keyword value: Header value. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class HttpMessageDiagnostic(_serialization.Model): - """Http message diagnostic settings. - - :ivar headers: Array of HTTP Headers to log. - :vartype headers: list[str] - :ivar body: Body logging settings. - :vartype body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings - :ivar data_masking: Data masking settings. - :vartype data_masking: ~azure.mgmt.apimanagement.models.DataMasking - """ - - _attribute_map = { - "headers": {"key": "headers", "type": "[str]"}, - "body": {"key": "body", "type": "BodyDiagnosticSettings"}, - "data_masking": {"key": "dataMasking", "type": "DataMasking"}, - } - - def __init__( - self, - *, - headers: Optional[List[str]] = None, - body: Optional["_models.BodyDiagnosticSettings"] = None, - data_masking: Optional["_models.DataMasking"] = None, - **kwargs: Any - ) -> None: - """ - :keyword headers: Array of HTTP Headers to log. - :paramtype headers: list[str] - :keyword body: Body logging settings. - :paramtype body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings - :keyword data_masking: Data masking settings. - :paramtype data_masking: ~azure.mgmt.apimanagement.models.DataMasking - """ - super().__init__(**kwargs) - self.headers = headers - self.body = body - self.data_masking = data_masking - - -class IdentityProviderBaseParameters(_serialization.Model): - """Identity Provider Base Parameter Properties. - - :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :vartype signin_tenant: str - :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :vartype allowed_tenants: list[str] - :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :vartype authority: str - :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signup_policy_name: str - :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signin_policy_name: str - :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :vartype profile_editing_policy_name: str - :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :vartype password_reset_policy_name: str - :ivar client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :vartype client_library: str - """ - - _validation = { - "allowed_tenants": {"max_items": 32, "min_items": 0}, - "signup_policy_name": {"min_length": 1}, - "signin_policy_name": {"min_length": 1}, - "profile_editing_policy_name": {"min_length": 1}, - "password_reset_policy_name": {"min_length": 1}, - "client_library": {"max_length": 16}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "signin_tenant": {"key": "signinTenant", "type": "str"}, - "allowed_tenants": {"key": "allowedTenants", "type": "[str]"}, - "authority": {"key": "authority", "type": "str"}, - "signup_policy_name": {"key": "signupPolicyName", "type": "str"}, - "signin_policy_name": {"key": "signinPolicyName", "type": "str"}, - "profile_editing_policy_name": {"key": "profileEditingPolicyName", "type": "str"}, - "password_reset_policy_name": {"key": "passwordResetPolicyName", "type": "str"}, - "client_library": {"key": "clientLibrary", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.IdentityProviderType"]] = None, - signin_tenant: Optional[str] = None, - allowed_tenants: Optional[List[str]] = None, - authority: Optional[str] = None, - signup_policy_name: Optional[str] = None, - signin_policy_name: Optional[str] = None, - profile_editing_policy_name: Optional[str] = None, - password_reset_policy_name: Optional[str] = None, - client_library: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :keyword signin_tenant: The TenantId to use instead of Common when logging into Active - Directory. - :paramtype signin_tenant: str - :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory - login. - :paramtype allowed_tenants: list[str] - :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :paramtype authority: str - :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signup_policy_name: str - :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signin_policy_name: str - :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype profile_editing_policy_name: str - :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype password_reset_policy_name: str - :keyword client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :paramtype client_library: str - """ - super().__init__(**kwargs) - self.type = type - self.signin_tenant = signin_tenant - self.allowed_tenants = allowed_tenants - self.authority = authority - self.signup_policy_name = signup_policy_name - self.signin_policy_name = signin_policy_name - self.profile_editing_policy_name = profile_editing_policy_name - self.password_reset_policy_name = password_reset_policy_name - self.client_library = client_library - - -class IdentityProviderContract(ProxyResource): - """Identity Provider 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 type_properties_type: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". - :vartype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :vartype signin_tenant: str - :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :vartype allowed_tenants: list[str] - :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :vartype authority: str - :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signup_policy_name: str - :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signin_policy_name: str - :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :vartype profile_editing_policy_name: str - :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :vartype password_reset_policy_name: str - :ivar client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :vartype client_library: str - :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID - for Facebook login, Client ID for Google login, App ID for Microsoft. - :vartype client_id: str - :ivar client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :vartype client_secret: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "allowed_tenants": {"max_items": 32, "min_items": 0}, - "signup_policy_name": {"min_length": 1}, - "signin_policy_name": {"min_length": 1}, - "profile_editing_policy_name": {"min_length": 1}, - "password_reset_policy_name": {"min_length": 1}, - "client_library": {"max_length": 16}, - "client_id": {"min_length": 1}, - "client_secret": {"min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "signin_tenant": {"key": "properties.signinTenant", "type": "str"}, - "allowed_tenants": {"key": "properties.allowedTenants", "type": "[str]"}, - "authority": {"key": "properties.authority", "type": "str"}, - "signup_policy_name": {"key": "properties.signupPolicyName", "type": "str"}, - "signin_policy_name": {"key": "properties.signinPolicyName", "type": "str"}, - "profile_editing_policy_name": {"key": "properties.profileEditingPolicyName", "type": "str"}, - "password_reset_policy_name": {"key": "properties.passwordResetPolicyName", "type": "str"}, - "client_library": {"key": "properties.clientLibrary", "type": "str"}, - "client_id": {"key": "properties.clientId", "type": "str"}, - "client_secret": {"key": "properties.clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - type_properties_type: Optional[Union[str, "_models.IdentityProviderType"]] = None, - signin_tenant: Optional[str] = None, - allowed_tenants: Optional[List[str]] = None, - authority: Optional[str] = None, - signup_policy_name: Optional[str] = None, - signin_policy_name: Optional[str] = None, - profile_editing_policy_name: Optional[str] = None, - password_reset_policy_name: Optional[str] = None, - client_library: Optional[str] = None, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type_properties_type: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". - :paramtype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :keyword signin_tenant: The TenantId to use instead of Common when logging into Active - Directory. - :paramtype signin_tenant: str - :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory - login. - :paramtype allowed_tenants: list[str] - :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :paramtype authority: str - :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signup_policy_name: str - :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signin_policy_name: str - :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype profile_editing_policy_name: str - :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype password_reset_policy_name: str - :keyword client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :paramtype client_library: str - :keyword client_id: Client Id of the Application in the external Identity Provider. It is App - ID for Facebook login, Client ID for Google login, App ID for Microsoft. - :paramtype client_id: str - :keyword client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :paramtype client_secret: str - """ - super().__init__(**kwargs) - self.type_properties_type = type_properties_type - self.signin_tenant = signin_tenant - self.allowed_tenants = allowed_tenants - self.authority = authority - self.signup_policy_name = signup_policy_name - self.signin_policy_name = signin_policy_name - self.profile_editing_policy_name = profile_editing_policy_name - self.password_reset_policy_name = password_reset_policy_name - self.client_library = client_library - self.client_id = client_id - self.client_secret = client_secret - - -class IdentityProviderContractProperties(IdentityProviderBaseParameters): - """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active - Directory which can be used to enable access to the API Management service developer portal for - all users. - - All required parameters must be populated in order to send to server. - - :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :vartype signin_tenant: str - :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :vartype allowed_tenants: list[str] - :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :vartype authority: str - :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signup_policy_name: str - :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signin_policy_name: str - :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :vartype profile_editing_policy_name: str - :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :vartype password_reset_policy_name: str - :ivar client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :vartype client_library: str - :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID - for Facebook login, Client ID for Google login, App ID for Microsoft. Required. - :vartype client_id: str - :ivar client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :vartype client_secret: str - """ - - _validation = { - "allowed_tenants": {"max_items": 32, "min_items": 0}, - "signup_policy_name": {"min_length": 1}, - "signin_policy_name": {"min_length": 1}, - "profile_editing_policy_name": {"min_length": 1}, - "password_reset_policy_name": {"min_length": 1}, - "client_library": {"max_length": 16}, - "client_id": {"required": True, "min_length": 1}, - "client_secret": {"min_length": 1}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "signin_tenant": {"key": "signinTenant", "type": "str"}, - "allowed_tenants": {"key": "allowedTenants", "type": "[str]"}, - "authority": {"key": "authority", "type": "str"}, - "signup_policy_name": {"key": "signupPolicyName", "type": "str"}, - "signin_policy_name": {"key": "signinPolicyName", "type": "str"}, - "profile_editing_policy_name": {"key": "profileEditingPolicyName", "type": "str"}, - "password_reset_policy_name": {"key": "passwordResetPolicyName", "type": "str"}, - "client_library": {"key": "clientLibrary", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - "client_secret": {"key": "clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - client_id: str, - type: Optional[Union[str, "_models.IdentityProviderType"]] = None, - signin_tenant: Optional[str] = None, - allowed_tenants: Optional[List[str]] = None, - authority: Optional[str] = None, - signup_policy_name: Optional[str] = None, - signin_policy_name: Optional[str] = None, - profile_editing_policy_name: Optional[str] = None, - password_reset_policy_name: Optional[str] = None, - client_library: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :keyword signin_tenant: The TenantId to use instead of Common when logging into Active - Directory. - :paramtype signin_tenant: str - :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory - login. - :paramtype allowed_tenants: list[str] - :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :paramtype authority: str - :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signup_policy_name: str - :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signin_policy_name: str - :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype profile_editing_policy_name: str - :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype password_reset_policy_name: str - :keyword client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :paramtype client_library: str - :keyword client_id: Client Id of the Application in the external Identity Provider. It is App - ID for Facebook login, Client ID for Google login, App ID for Microsoft. Required. - :paramtype client_id: str - :keyword client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :paramtype client_secret: str - """ - super().__init__( - type=type, - signin_tenant=signin_tenant, - allowed_tenants=allowed_tenants, - authority=authority, - signup_policy_name=signup_policy_name, - signin_policy_name=signin_policy_name, - profile_editing_policy_name=profile_editing_policy_name, - password_reset_policy_name=password_reset_policy_name, - client_library=client_library, - **kwargs - ) - self.client_id = client_id - self.client_secret = client_secret - - -class IdentityProviderCreateContract(ProxyResource): - """Identity Provider 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 type_properties_type: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". - :vartype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :vartype signin_tenant: str - :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :vartype allowed_tenants: list[str] - :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :vartype authority: str - :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signup_policy_name: str - :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signin_policy_name: str - :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :vartype profile_editing_policy_name: str - :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :vartype password_reset_policy_name: str - :ivar client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :vartype client_library: str - :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID - for Facebook login, Client ID for Google login, App ID for Microsoft. - :vartype client_id: str - :ivar client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :vartype client_secret: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "allowed_tenants": {"max_items": 32, "min_items": 0}, - "signup_policy_name": {"min_length": 1}, - "signin_policy_name": {"min_length": 1}, - "profile_editing_policy_name": {"min_length": 1}, - "password_reset_policy_name": {"min_length": 1}, - "client_library": {"max_length": 16}, - "client_id": {"min_length": 1}, - "client_secret": {"min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "type_properties_type": {"key": "properties.type", "type": "str"}, - "signin_tenant": {"key": "properties.signinTenant", "type": "str"}, - "allowed_tenants": {"key": "properties.allowedTenants", "type": "[str]"}, - "authority": {"key": "properties.authority", "type": "str"}, - "signup_policy_name": {"key": "properties.signupPolicyName", "type": "str"}, - "signin_policy_name": {"key": "properties.signinPolicyName", "type": "str"}, - "profile_editing_policy_name": {"key": "properties.profileEditingPolicyName", "type": "str"}, - "password_reset_policy_name": {"key": "properties.passwordResetPolicyName", "type": "str"}, - "client_library": {"key": "properties.clientLibrary", "type": "str"}, - "client_id": {"key": "properties.clientId", "type": "str"}, - "client_secret": {"key": "properties.clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - type_properties_type: Optional[Union[str, "_models.IdentityProviderType"]] = None, - signin_tenant: Optional[str] = None, - allowed_tenants: Optional[List[str]] = None, - authority: Optional[str] = None, - signup_policy_name: Optional[str] = None, - signin_policy_name: Optional[str] = None, - profile_editing_policy_name: Optional[str] = None, - password_reset_policy_name: Optional[str] = None, - client_library: Optional[str] = None, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type_properties_type: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". - :paramtype type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :keyword signin_tenant: The TenantId to use instead of Common when logging into Active - Directory. - :paramtype signin_tenant: str - :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory - login. - :paramtype allowed_tenants: list[str] - :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :paramtype authority: str - :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signup_policy_name: str - :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signin_policy_name: str - :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype profile_editing_policy_name: str - :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype password_reset_policy_name: str - :keyword client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :paramtype client_library: str - :keyword client_id: Client Id of the Application in the external Identity Provider. It is App - ID for Facebook login, Client ID for Google login, App ID for Microsoft. - :paramtype client_id: str - :keyword client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. - :paramtype client_secret: str - """ - super().__init__(**kwargs) - self.type_properties_type = type_properties_type - self.signin_tenant = signin_tenant - self.allowed_tenants = allowed_tenants - self.authority = authority - self.signup_policy_name = signup_policy_name - self.signin_policy_name = signin_policy_name - self.profile_editing_policy_name = profile_editing_policy_name - self.password_reset_policy_name = password_reset_policy_name - self.client_library = client_library - self.client_id = client_id - self.client_secret = client_secret - - -class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): - """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active - Directory which can be used to enable access to the API Management service developer portal for - all users. - - All required parameters must be populated in order to send to server. - - :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :vartype signin_tenant: str - :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :vartype allowed_tenants: list[str] - :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :vartype authority: str - :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signup_policy_name: str - :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signin_policy_name: str - :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :vartype profile_editing_policy_name: str - :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :vartype password_reset_policy_name: str - :ivar client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :vartype client_library: str - :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID - for Facebook login, Client ID for Google login, App ID for Microsoft. Required. - :vartype client_id: str - :ivar client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. Required. - :vartype client_secret: str - """ - - _validation = { - "allowed_tenants": {"max_items": 32, "min_items": 0}, - "signup_policy_name": {"min_length": 1}, - "signin_policy_name": {"min_length": 1}, - "profile_editing_policy_name": {"min_length": 1}, - "password_reset_policy_name": {"min_length": 1}, - "client_library": {"max_length": 16}, - "client_id": {"required": True, "min_length": 1}, - "client_secret": {"required": True, "min_length": 1}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "signin_tenant": {"key": "signinTenant", "type": "str"}, - "allowed_tenants": {"key": "allowedTenants", "type": "[str]"}, - "authority": {"key": "authority", "type": "str"}, - "signup_policy_name": {"key": "signupPolicyName", "type": "str"}, - "signin_policy_name": {"key": "signinPolicyName", "type": "str"}, - "profile_editing_policy_name": {"key": "profileEditingPolicyName", "type": "str"}, - "password_reset_policy_name": {"key": "passwordResetPolicyName", "type": "str"}, - "client_library": {"key": "clientLibrary", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - "client_secret": {"key": "clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - client_id: str, - client_secret: str, - type: Optional[Union[str, "_models.IdentityProviderType"]] = None, - signin_tenant: Optional[str] = None, - allowed_tenants: Optional[List[str]] = None, - authority: Optional[str] = None, - signup_policy_name: Optional[str] = None, - signin_policy_name: Optional[str] = None, - profile_editing_policy_name: Optional[str] = None, - password_reset_policy_name: Optional[str] = None, - client_library: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :keyword signin_tenant: The TenantId to use instead of Common when logging into Active - Directory. - :paramtype signin_tenant: str - :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory - login. - :paramtype allowed_tenants: list[str] - :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :paramtype authority: str - :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signup_policy_name: str - :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signin_policy_name: str - :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype profile_editing_policy_name: str - :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype password_reset_policy_name: str - :keyword client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :paramtype client_library: str - :keyword client_id: Client Id of the Application in the external Identity Provider. It is App - ID for Facebook login, Client ID for Google login, App ID for Microsoft. Required. - :paramtype client_id: str - :keyword client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! - Use '/listSecrets' POST request to get the value. Required. - :paramtype client_secret: str - """ - super().__init__( - type=type, - signin_tenant=signin_tenant, - allowed_tenants=allowed_tenants, - authority=authority, - signup_policy_name=signup_policy_name, - signin_policy_name=signin_policy_name, - profile_editing_policy_name=profile_editing_policy_name, - password_reset_policy_name=password_reset_policy_name, - client_library=client_library, - **kwargs - ) - self.client_id = client_id - self.client_secret = client_secret - - -class IdentityProviderList(_serialization.Model): - """List of all the Identity Providers configured on the service instance. - - :ivar value: Identity Provider configuration values. - :vartype value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] - :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": "[IdentityProviderContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.IdentityProviderContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Identity Provider configuration values. - :paramtype value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] - :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 IdentityProviderUpdateParameters(_serialization.Model): - """Parameters supplied to update Identity Provider. - - :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :vartype signin_tenant: str - :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :vartype allowed_tenants: list[str] - :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :vartype authority: str - :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signup_policy_name: str - :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signin_policy_name: str - :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :vartype profile_editing_policy_name: str - :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :vartype password_reset_policy_name: str - :ivar client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :vartype client_library: str - :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID - for Facebook login, Client ID for Google login, App ID for Microsoft. - :vartype client_id: str - :ivar client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. - :vartype client_secret: str - """ - - _validation = { - "allowed_tenants": {"max_items": 32, "min_items": 0}, - "signup_policy_name": {"min_length": 1}, - "signin_policy_name": {"min_length": 1}, - "profile_editing_policy_name": {"min_length": 1}, - "password_reset_policy_name": {"min_length": 1}, - "client_library": {"max_length": 16}, - "client_id": {"min_length": 1}, - "client_secret": {"min_length": 1}, - } - - _attribute_map = { - "type": {"key": "properties.type", "type": "str"}, - "signin_tenant": {"key": "properties.signinTenant", "type": "str"}, - "allowed_tenants": {"key": "properties.allowedTenants", "type": "[str]"}, - "authority": {"key": "properties.authority", "type": "str"}, - "signup_policy_name": {"key": "properties.signupPolicyName", "type": "str"}, - "signin_policy_name": {"key": "properties.signinPolicyName", "type": "str"}, - "profile_editing_policy_name": {"key": "properties.profileEditingPolicyName", "type": "str"}, - "password_reset_policy_name": {"key": "properties.passwordResetPolicyName", "type": "str"}, - "client_library": {"key": "properties.clientLibrary", "type": "str"}, - "client_id": {"key": "properties.clientId", "type": "str"}, - "client_secret": {"key": "properties.clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.IdentityProviderType"]] = None, - signin_tenant: Optional[str] = None, - allowed_tenants: Optional[List[str]] = None, - authority: Optional[str] = None, - signup_policy_name: Optional[str] = None, - signin_policy_name: Optional[str] = None, - profile_editing_policy_name: Optional[str] = None, - password_reset_policy_name: Optional[str] = None, - client_library: Optional[str] = None, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :keyword signin_tenant: The TenantId to use instead of Common when logging into Active - Directory. - :paramtype signin_tenant: str - :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory - login. - :paramtype allowed_tenants: list[str] - :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :paramtype authority: str - :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signup_policy_name: str - :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signin_policy_name: str - :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype profile_editing_policy_name: str - :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype password_reset_policy_name: str - :keyword client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :paramtype client_library: str - :keyword client_id: Client Id of the Application in the external Identity Provider. It is App - ID for Facebook login, Client ID for Google login, App ID for Microsoft. - :paramtype client_id: str - :keyword client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. - :paramtype client_secret: str - """ - super().__init__(**kwargs) - self.type = type - self.signin_tenant = signin_tenant - self.allowed_tenants = allowed_tenants - self.authority = authority - self.signup_policy_name = signup_policy_name - self.signin_policy_name = signin_policy_name - self.profile_editing_policy_name = profile_editing_policy_name - self.password_reset_policy_name = password_reset_policy_name - self.client_library = client_library - self.client_id = client_id - self.client_secret = client_secret - - -class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): - """Parameters supplied to the Update Identity Provider operation. - - :ivar type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :vartype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :ivar signin_tenant: The TenantId to use instead of Common when logging into Active Directory. - :vartype signin_tenant: str - :ivar allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. - :vartype allowed_tenants: list[str] - :ivar authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :vartype authority: str - :ivar signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signup_policy_name: str - :ivar signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :vartype signin_policy_name: str - :ivar profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :vartype profile_editing_policy_name: str - :ivar password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity - Provider. - :vartype password_reset_policy_name: str - :ivar client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :vartype client_library: str - :ivar client_id: Client Id of the Application in the external Identity Provider. It is App ID - for Facebook login, Client ID for Google login, App ID for Microsoft. - :vartype client_id: str - :ivar client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. - :vartype client_secret: str - """ - - _validation = { - "allowed_tenants": {"max_items": 32, "min_items": 0}, - "signup_policy_name": {"min_length": 1}, - "signin_policy_name": {"min_length": 1}, - "profile_editing_policy_name": {"min_length": 1}, - "password_reset_policy_name": {"min_length": 1}, - "client_library": {"max_length": 16}, - "client_id": {"min_length": 1}, - "client_secret": {"min_length": 1}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "signin_tenant": {"key": "signinTenant", "type": "str"}, - "allowed_tenants": {"key": "allowedTenants", "type": "[str]"}, - "authority": {"key": "authority", "type": "str"}, - "signup_policy_name": {"key": "signupPolicyName", "type": "str"}, - "signin_policy_name": {"key": "signinPolicyName", "type": "str"}, - "profile_editing_policy_name": {"key": "profileEditingPolicyName", "type": "str"}, - "password_reset_policy_name": {"key": "passwordResetPolicyName", "type": "str"}, - "client_library": {"key": "clientLibrary", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - "client_secret": {"key": "clientSecret", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.IdentityProviderType"]] = None, - signin_tenant: Optional[str] = None, - allowed_tenants: Optional[List[str]] = None, - authority: Optional[str] = None, - signup_policy_name: Optional[str] = None, - signin_policy_name: Optional[str] = None, - profile_editing_policy_name: Optional[str] = None, - password_reset_policy_name: Optional[str] = None, - client_library: Optional[str] = None, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: Identity Provider Type identifier. Known values are: "facebook", "google", - "microsoft", "twitter", "aad", and "aadB2C". - :paramtype type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :keyword signin_tenant: The TenantId to use instead of Common when logging into Active - Directory. - :paramtype signin_tenant: str - :keyword allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory - login. - :paramtype allowed_tenants: list[str] - :keyword authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. - :paramtype authority: str - :keyword signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signup_policy_name: str - :keyword signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. - :paramtype signin_policy_name: str - :keyword profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype profile_editing_policy_name: str - :keyword password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C - Identity Provider. - :paramtype password_reset_policy_name: str - :keyword client_library: The client library to be used in the developer portal. Only applies to - AAD and AAD B2C Identity Provider. - :paramtype client_library: str - :keyword client_id: Client Id of the Application in the external Identity Provider. It is App - ID for Facebook login, Client ID for Google login, App ID for Microsoft. - :paramtype client_id: str - :keyword client_secret: Client secret of the Application in external Identity Provider, used to - authenticate login request. For example, it is App Secret for Facebook login, API Key for - Google login, Public Key for Microsoft. - :paramtype client_secret: str - """ - super().__init__( - type=type, - signin_tenant=signin_tenant, - allowed_tenants=allowed_tenants, - authority=authority, - signup_policy_name=signup_policy_name, - signin_policy_name=signin_policy_name, - profile_editing_policy_name=profile_editing_policy_name, - password_reset_policy_name=password_reset_policy_name, - client_library=client_library, - **kwargs - ) - self.client_id = client_id - self.client_secret = client_secret - - -class IssueAttachmentCollection(_serialization.Model): - """Paged Issue Attachment list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Issue Attachment values. - :vartype value: list[~azure.mgmt.apimanagement.models.IssueAttachmentContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[IssueAttachmentContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class IssueAttachmentContract(ProxyResource): - """Issue Attachment 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 title: Filename by which the binary data will be saved. - :vartype title: str - :ivar content_format: Either 'link' if content is provided via an HTTP link or the MIME type of - the Base64-encoded binary data provided in the 'content' property. - :vartype content_format: str - :ivar content: An HTTP link or Base64-encoded binary data. - :vartype content: 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"}, - "title": {"key": "properties.title", "type": "str"}, - "content_format": {"key": "properties.contentFormat", "type": "str"}, - "content": {"key": "properties.content", "type": "str"}, - } - - def __init__( - self, - *, - title: Optional[str] = None, - content_format: Optional[str] = None, - content: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword title: Filename by which the binary data will be saved. - :paramtype title: str - :keyword content_format: Either 'link' if content is provided via an HTTP link or the MIME type - of the Base64-encoded binary data provided in the 'content' property. - :paramtype content_format: str - :keyword content: An HTTP link or Base64-encoded binary data. - :paramtype content: str - """ - super().__init__(**kwargs) - self.title = title - self.content_format = content_format - self.content = content - - -class IssueCollection(_serialization.Model): - """Paged Issue list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Issue values. - :vartype value: list[~azure.mgmt.apimanagement.models.IssueContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[IssueContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class IssueCommentCollection(_serialization.Model): - """Paged Issue Comment list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Issue Comment values. - :vartype value: list[~azure.mgmt.apimanagement.models.IssueCommentContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[IssueCommentContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class IssueCommentContract(ProxyResource): - """Issue Comment 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 text: Comment text. - :vartype text: str - :ivar created_date: Date and time when the comment was created. - :vartype created_date: ~datetime.datetime - :ivar user_id: A resource identifier for the user who left the comment. - :vartype user_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"}, - "text": {"key": "properties.text", "type": "str"}, - "created_date": {"key": "properties.createdDate", "type": "iso-8601"}, - "user_id": {"key": "properties.userId", "type": "str"}, - } - - def __init__( - self, - *, - text: Optional[str] = None, - created_date: Optional[datetime.datetime] = None, - user_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword text: Comment text. - :paramtype text: str - :keyword created_date: Date and time when the comment was created. - :paramtype created_date: ~datetime.datetime - :keyword user_id: A resource identifier for the user who left the comment. - :paramtype user_id: str - """ - super().__init__(**kwargs) - self.text = text - self.created_date = created_date - self.user_id = user_id - - -class IssueContract(ProxyResource): - """Issue 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 created_date: Date and time when the issue was created. - :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", - and "closed". - :vartype state: str or ~azure.mgmt.apimanagement.models.State - :ivar api_id: A resource identifier for the API the issue was created for. - :vartype api_id: str - :ivar title: The issue title. - :vartype title: str - :ivar description: Text describing the issue. - :vartype description: str - :ivar user_id: A resource identifier for the user created the issue. - :vartype user_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"}, - "created_date": {"key": "properties.createdDate", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - "api_id": {"key": "properties.apiId", "type": "str"}, - "title": {"key": "properties.title", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "user_id": {"key": "properties.userId", "type": "str"}, - } - - def __init__( - self, - *, - created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "_models.State"]] = None, - api_id: Optional[str] = None, - title: Optional[str] = None, - description: Optional[str] = None, - user_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_date: Date and time when the issue was created. - :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", - "resolved", and "closed". - :paramtype state: str or ~azure.mgmt.apimanagement.models.State - :keyword api_id: A resource identifier for the API the issue was created for. - :paramtype api_id: str - :keyword title: The issue title. - :paramtype title: str - :keyword description: Text describing the issue. - :paramtype description: str - :keyword user_id: A resource identifier for the user created the issue. - :paramtype user_id: str - """ - super().__init__(**kwargs) - self.created_date = created_date - self.state = state - self.api_id = api_id - self.title = title - self.description = description - self.user_id = user_id - - -class IssueContractBaseProperties(_serialization.Model): - """Issue contract Base Properties. - - :ivar created_date: Date and time when the issue was created. - :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", - and "closed". - :vartype state: str or ~azure.mgmt.apimanagement.models.State - :ivar api_id: A resource identifier for the API the issue was created for. - :vartype api_id: str - """ - - _attribute_map = { - "created_date": {"key": "createdDate", "type": "iso-8601"}, - "state": {"key": "state", "type": "str"}, - "api_id": {"key": "apiId", "type": "str"}, - } - - def __init__( - self, - *, - created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "_models.State"]] = None, - api_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_date: Date and time when the issue was created. - :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", - "resolved", and "closed". - :paramtype state: str or ~azure.mgmt.apimanagement.models.State - :keyword api_id: A resource identifier for the API the issue was created for. - :paramtype api_id: str - """ - super().__init__(**kwargs) - self.created_date = created_date - self.state = state - self.api_id = api_id - - -class IssueContractProperties(IssueContractBaseProperties): - """Issue contract Properties. - - All required parameters must be populated in order to send to server. - - :ivar created_date: Date and time when the issue was created. - :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", - and "closed". - :vartype state: str or ~azure.mgmt.apimanagement.models.State - :ivar api_id: A resource identifier for the API the issue was created for. - :vartype api_id: str - :ivar title: The issue title. Required. - :vartype title: str - :ivar description: Text describing the issue. Required. - :vartype description: str - :ivar user_id: A resource identifier for the user created the issue. Required. - :vartype user_id: str - """ - - _validation = { - "title": {"required": True}, - "description": {"required": True}, - "user_id": {"required": True}, - } - - _attribute_map = { - "created_date": {"key": "createdDate", "type": "iso-8601"}, - "state": {"key": "state", "type": "str"}, - "api_id": {"key": "apiId", "type": "str"}, - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "user_id": {"key": "userId", "type": "str"}, - } - - def __init__( - self, - *, - title: str, - description: str, - user_id: str, - created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "_models.State"]] = None, - api_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_date: Date and time when the issue was created. - :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", - "resolved", and "closed". - :paramtype state: str or ~azure.mgmt.apimanagement.models.State - :keyword api_id: A resource identifier for the API the issue was created for. - :paramtype api_id: str - :keyword title: The issue title. Required. - :paramtype title: str - :keyword description: Text describing the issue. Required. - :paramtype description: str - :keyword user_id: A resource identifier for the user created the issue. Required. - :paramtype user_id: str - """ - super().__init__(created_date=created_date, state=state, api_id=api_id, **kwargs) - self.title = title - self.description = description - self.user_id = user_id - - -class IssueUpdateContract(_serialization.Model): - """Issue update Parameters. - - :ivar created_date: Date and time when the issue was created. - :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", - and "closed". - :vartype state: str or ~azure.mgmt.apimanagement.models.State - :ivar api_id: A resource identifier for the API the issue was created for. - :vartype api_id: str - :ivar title: The issue title. - :vartype title: str - :ivar description: Text describing the issue. - :vartype description: str - :ivar user_id: A resource identifier for the user created the issue. - :vartype user_id: str - """ - - _attribute_map = { - "created_date": {"key": "properties.createdDate", "type": "iso-8601"}, - "state": {"key": "properties.state", "type": "str"}, - "api_id": {"key": "properties.apiId", "type": "str"}, - "title": {"key": "properties.title", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "user_id": {"key": "properties.userId", "type": "str"}, - } - - def __init__( - self, - *, - created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "_models.State"]] = None, - api_id: Optional[str] = None, - title: Optional[str] = None, - description: Optional[str] = None, - user_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_date: Date and time when the issue was created. - :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", - "resolved", and "closed". - :paramtype state: str or ~azure.mgmt.apimanagement.models.State - :keyword api_id: A resource identifier for the API the issue was created for. - :paramtype api_id: str - :keyword title: The issue title. - :paramtype title: str - :keyword description: Text describing the issue. - :paramtype description: str - :keyword user_id: A resource identifier for the user created the issue. - :paramtype user_id: str - """ - super().__init__(**kwargs) - self.created_date = created_date - self.state = state - self.api_id = api_id - self.title = title - self.description = description - self.user_id = user_id - - -class IssueUpdateContractProperties(IssueContractBaseProperties): - """Issue contract Update Properties. - - :ivar created_date: Date and time when the issue was created. - :vartype created_date: ~datetime.datetime - :ivar state: Status of the issue. Known values are: "proposed", "open", "removed", "resolved", - and "closed". - :vartype state: str or ~azure.mgmt.apimanagement.models.State - :ivar api_id: A resource identifier for the API the issue was created for. - :vartype api_id: str - :ivar title: The issue title. - :vartype title: str - :ivar description: Text describing the issue. - :vartype description: str - :ivar user_id: A resource identifier for the user created the issue. - :vartype user_id: str - """ - - _attribute_map = { - "created_date": {"key": "createdDate", "type": "iso-8601"}, - "state": {"key": "state", "type": "str"}, - "api_id": {"key": "apiId", "type": "str"}, - "title": {"key": "title", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "user_id": {"key": "userId", "type": "str"}, - } - - def __init__( - self, - *, - created_date: Optional[datetime.datetime] = None, - state: Optional[Union[str, "_models.State"]] = None, - api_id: Optional[str] = None, - title: Optional[str] = None, - description: Optional[str] = None, - user_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_date: Date and time when the issue was created. - :paramtype created_date: ~datetime.datetime - :keyword state: Status of the issue. Known values are: "proposed", "open", "removed", - "resolved", and "closed". - :paramtype state: str or ~azure.mgmt.apimanagement.models.State - :keyword api_id: A resource identifier for the API the issue was created for. - :paramtype api_id: str - :keyword title: The issue title. - :paramtype title: str - :keyword description: Text describing the issue. - :paramtype description: str - :keyword user_id: A resource identifier for the user created the issue. - :paramtype user_id: str - """ - super().__init__(created_date=created_date, state=state, api_id=api_id, **kwargs) - self.title = title - self.description = description - self.user_id = user_id - - -class KeyVaultContractCreateProperties(_serialization.Model): - """Create keyVault contract details. - - :ivar secret_identifier: Key vault secret identifier for fetching secret. Providing a versioned - secret will prevent auto-refresh. This requires API Management service to be configured with - aka.ms/apimmsi. - :vartype secret_identifier: str - :ivar identity_client_id: Null for SystemAssignedIdentity or Client Id for UserAssignedIdentity - , which will be used to access key vault secret. - :vartype identity_client_id: str - """ - - _attribute_map = { - "secret_identifier": {"key": "secretIdentifier", "type": "str"}, - "identity_client_id": {"key": "identityClientId", "type": "str"}, - } - - def __init__( - self, *, secret_identifier: Optional[str] = None, identity_client_id: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword secret_identifier: Key vault secret identifier for fetching secret. Providing a - versioned secret will prevent auto-refresh. This requires API Management service to be - configured with aka.ms/apimmsi. - :paramtype secret_identifier: str - :keyword identity_client_id: Null for SystemAssignedIdentity or Client Id for - UserAssignedIdentity , which will be used to access key vault secret. - :paramtype identity_client_id: str - """ - super().__init__(**kwargs) - self.secret_identifier = secret_identifier - self.identity_client_id = identity_client_id - - -class KeyVaultContractProperties(KeyVaultContractCreateProperties): - """KeyVault contract details. - - :ivar secret_identifier: Key vault secret identifier for fetching secret. Providing a versioned - secret will prevent auto-refresh. This requires API Management service to be configured with - aka.ms/apimmsi. - :vartype secret_identifier: str - :ivar identity_client_id: Null for SystemAssignedIdentity or Client Id for UserAssignedIdentity - , which will be used to access key vault secret. - :vartype identity_client_id: str - :ivar last_status: Last time sync and refresh status of secret from key vault. - :vartype last_status: - ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties - """ - - _attribute_map = { - "secret_identifier": {"key": "secretIdentifier", "type": "str"}, - "identity_client_id": {"key": "identityClientId", "type": "str"}, - "last_status": {"key": "lastStatus", "type": "KeyVaultLastAccessStatusContractProperties"}, - } - - def __init__( - self, - *, - secret_identifier: Optional[str] = None, - identity_client_id: Optional[str] = None, - last_status: Optional["_models.KeyVaultLastAccessStatusContractProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword secret_identifier: Key vault secret identifier for fetching secret. Providing a - versioned secret will prevent auto-refresh. This requires API Management service to be - configured with aka.ms/apimmsi. - :paramtype secret_identifier: str - :keyword identity_client_id: Null for SystemAssignedIdentity or Client Id for - UserAssignedIdentity , which will be used to access key vault secret. - :paramtype identity_client_id: str - :keyword last_status: Last time sync and refresh status of secret from key vault. - :paramtype last_status: - ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties - """ - super().__init__(secret_identifier=secret_identifier, identity_client_id=identity_client_id, **kwargs) - self.last_status = last_status - - -class KeyVaultLastAccessStatusContractProperties(_serialization.Model): # pylint: disable=name-too-long - """Issue contract Update Properties. - - :ivar code: Last status code for sync and refresh of secret from key vault. - :vartype code: str - :ivar message: Details of the error else empty. - :vartype message: str - :ivar time_stamp_utc: Last time secret was accessed. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype time_stamp_utc: ~datetime.datetime - """ - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "time_stamp_utc": {"key": "timeStampUtc", "type": "iso-8601"}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - time_stamp_utc: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword code: Last status code for sync and refresh of secret from key vault. - :paramtype code: str - :keyword message: Details of the error else empty. - :paramtype message: str - :keyword time_stamp_utc: Last time secret was accessed. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype time_stamp_utc: ~datetime.datetime - """ - super().__init__(**kwargs) - self.code = code - self.message = message - self.time_stamp_utc = time_stamp_utc - - -class LoggerCollection(_serialization.Model): - """Paged Logger list representation. - - :ivar value: Logger values. - :vartype value: list[~azure.mgmt.apimanagement.models.LoggerContract] - :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": "[LoggerContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.LoggerContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Logger values. - :paramtype value: list[~azure.mgmt.apimanagement.models.LoggerContract] - :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 LoggerContract(ProxyResource): - """Logger 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 logger_type: Logger type. Known values are: "azureEventHub", "applicationInsights", and - "azureMonitor". - :vartype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType - :ivar description: Logger description. - :vartype description: str - :ivar credentials: The name and SendRule connection string of the event hub for azureEventHub - logger. - Instrumentation key for applicationInsights logger. - :vartype credentials: dict[str, str] - :ivar is_buffered: Whether records are buffered in the logger before publishing. Default is - assumed to be true. - :vartype is_buffered: bool - :ivar resource_id: Azure Resource Id of a log target (either Azure Event Hub resource or Azure - Application Insights resource). - :vartype resource_id: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "description": {"max_length": 256}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "logger_type": {"key": "properties.loggerType", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "credentials": {"key": "properties.credentials", "type": "{str}"}, - "is_buffered": {"key": "properties.isBuffered", "type": "bool"}, - "resource_id": {"key": "properties.resourceId", "type": "str"}, - } - - def __init__( - self, - *, - logger_type: Optional[Union[str, "_models.LoggerType"]] = None, - description: Optional[str] = None, - credentials: Optional[Dict[str, str]] = None, - is_buffered: Optional[bool] = None, - resource_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword logger_type: Logger type. Known values are: "azureEventHub", "applicationInsights", - and "azureMonitor". - :paramtype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType - :keyword description: Logger description. - :paramtype description: str - :keyword credentials: The name and SendRule connection string of the event hub for - azureEventHub logger. - Instrumentation key for applicationInsights logger. - :paramtype credentials: dict[str, str] - :keyword is_buffered: Whether records are buffered in the logger before publishing. Default is - assumed to be true. - :paramtype is_buffered: bool - :keyword resource_id: Azure Resource Id of a log target (either Azure Event Hub resource or - Azure Application Insights resource). - :paramtype resource_id: str - """ - super().__init__(**kwargs) - self.logger_type = logger_type - self.description = description - self.credentials = credentials - self.is_buffered = is_buffered - self.resource_id = resource_id - - -class LoggerUpdateContract(_serialization.Model): - """Logger update contract. - - :ivar logger_type: Logger type. Known values are: "azureEventHub", "applicationInsights", and - "azureMonitor". - :vartype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType - :ivar description: Logger description. - :vartype description: str - :ivar credentials: Logger credentials. - :vartype credentials: dict[str, str] - :ivar is_buffered: Whether records are buffered in the logger before publishing. Default is - assumed to be true. - :vartype is_buffered: bool - """ - - _attribute_map = { - "logger_type": {"key": "properties.loggerType", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "credentials": {"key": "properties.credentials", "type": "{str}"}, - "is_buffered": {"key": "properties.isBuffered", "type": "bool"}, - } - - def __init__( - self, - *, - logger_type: Optional[Union[str, "_models.LoggerType"]] = None, - description: Optional[str] = None, - credentials: Optional[Dict[str, str]] = None, - is_buffered: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword logger_type: Logger type. Known values are: "azureEventHub", "applicationInsights", - and "azureMonitor". - :paramtype logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType - :keyword description: Logger description. - :paramtype description: str - :keyword credentials: Logger credentials. - :paramtype credentials: dict[str, str] - :keyword is_buffered: Whether records are buffered in the logger before publishing. Default is - assumed to be true. - :paramtype is_buffered: bool - """ - super().__init__(**kwargs) - self.logger_type = logger_type - self.description = description - self.credentials = credentials - 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. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.NamedValueContract] - :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": "[NamedValueContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.NamedValueContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.NamedValueContract] - :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 NamedValueContract(ProxyResource): - """NamedValue 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 tags: Optional tags that when provided can be used to filter the NamedValue list. - :vartype tags: list[str] - :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :vartype secret: bool - :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :vartype display_name: str - :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. - :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 = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "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 = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "properties.tags", "type": "[str]"}, - "secret": {"key": "properties.secret", "type": "bool"}, - "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__( - self, - *, - tags: Optional[List[str]] = None, - secret: Optional[bool] = None, - display_name: Optional[str] = None, - value: Optional[str] = None, - key_vault: Optional["_models.KeyVaultContractProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Optional tags that when provided can be used to filter the NamedValue list. - :paramtype tags: list[str] - :keyword secret: Determines whether the value is a secret and should be encrypted or not. - Default value is false. - :paramtype secret: bool - :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :paramtype display_name: str - :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. - :paramtype value: str - :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.secret = secret - self.display_name = display_name - self.value = value - self.key_vault = key_vault - self.provisioning_state = None - - -class NamedValueEntityBaseParameters(_serialization.Model): - """NamedValue Entity Base Parameters set. - - :ivar tags: Optional tags that when provided can be used to filter the NamedValue list. - :vartype tags: list[str] - :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :vartype secret: bool - """ - - _validation = { - "tags": {"max_items": 32, "min_items": 0}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "[str]"}, - "secret": {"key": "secret", "type": "bool"}, - } - - def __init__(self, *, tags: Optional[List[str]] = None, secret: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword tags: Optional tags that when provided can be used to filter the NamedValue list. - :paramtype tags: list[str] - :keyword secret: Determines whether the value is a secret and should be encrypted or not. - Default value is false. - :paramtype secret: bool - """ - super().__init__(**kwargs) - self.tags = tags - self.secret = secret - - -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. - :vartype tags: list[str] - :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :vartype secret: bool - :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. Required. - :vartype display_name: str - :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. - :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 = { - "tags": {"key": "tags", "type": "[str]"}, - "secret": {"key": "secret", "type": "bool"}, - "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__( - self, - *, - display_name: str, - tags: Optional[List[str]] = None, - secret: Optional[bool] = None, - value: Optional[str] = None, - key_vault: Optional["_models.KeyVaultContractProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Optional tags that when provided can be used to filter the NamedValue list. - :paramtype tags: list[str] - :keyword secret: Determines whether the value is a secret and should be encrypted or not. - Default value is false. - :paramtype secret: bool - :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. Required. - :paramtype display_name: str - :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. - :paramtype value: str - :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties - """ - super().__init__(tags=tags, secret=secret, **kwargs) - self.display_name = display_name - self.value = value - self.key_vault = key_vault - self.provisioning_state = None - - -class NamedValueCreateContract(ProxyResource): - """NamedValue 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 tags: Optional tags that when provided can be used to filter the NamedValue list. - :vartype tags: list[str] - :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :vartype secret: bool - :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :vartype display_name: str - :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. - :vartype value: str - :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "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}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "tags": {"key": "properties.tags", "type": "[str]"}, - "secret": {"key": "properties.secret", "type": "bool"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "value": {"key": "properties.value", "type": "str"}, - "key_vault": {"key": "properties.keyVault", "type": "KeyVaultContractCreateProperties"}, - } - - def __init__( - self, - *, - tags: Optional[List[str]] = None, - secret: Optional[bool] = None, - display_name: Optional[str] = None, - value: Optional[str] = None, - key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Optional tags that when provided can be used to filter the NamedValue list. - :paramtype tags: list[str] - :keyword secret: Determines whether the value is a secret and should be encrypted or not. - Default value is false. - :paramtype secret: bool - :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :paramtype display_name: str - :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. - :paramtype value: str - :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.secret = secret - self.display_name = display_name - self.value = value - self.key_vault = key_vault - - -class NamedValueCreateContractProperties(NamedValueEntityBaseParameters): - """NamedValue Contract properties. - - 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. - :vartype tags: list[str] - :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :vartype secret: bool - :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. Required. - :vartype display_name: str - :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. - :vartype value: str - :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - - _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}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "[str]"}, - "secret": {"key": "secret", "type": "bool"}, - "display_name": {"key": "displayName", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "key_vault": {"key": "keyVault", "type": "KeyVaultContractCreateProperties"}, - } - - def __init__( - self, - *, - display_name: str, - tags: Optional[List[str]] = None, - secret: Optional[bool] = None, - value: Optional[str] = None, - key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Optional tags that when provided can be used to filter the NamedValue list. - :paramtype tags: list[str] - :keyword secret: Determines whether the value is a secret and should be encrypted or not. - Default value is false. - :paramtype secret: bool - :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. Required. - :paramtype display_name: str - :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. - :paramtype value: str - :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - super().__init__(tags=tags, secret=secret, **kwargs) - self.display_name = display_name - self.value = value - self.key_vault = key_vault - - -class NamedValueSecretContract(_serialization.Model): - """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - - :ivar value: This is secret value of the NamedValue entity. - :vartype value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: This is secret value of the NamedValue entity. - :paramtype value: str - """ - super().__init__(**kwargs) - self.value = value - - -class NamedValueUpdateParameterProperties(NamedValueEntityBaseParameters): - """NamedValue Contract properties. - - :ivar tags: Optional tags that when provided can be used to filter the NamedValue list. - :vartype tags: list[str] - :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :vartype secret: bool - :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :vartype display_name: str - :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. - :vartype value: str - :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - - _validation = { - "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, "min_length": 1}, - } - - _attribute_map = { - "tags": {"key": "tags", "type": "[str]"}, - "secret": {"key": "secret", "type": "bool"}, - "display_name": {"key": "displayName", "type": "str"}, - "value": {"key": "value", "type": "str"}, - "key_vault": {"key": "keyVault", "type": "KeyVaultContractCreateProperties"}, - } - - def __init__( - self, - *, - tags: Optional[List[str]] = None, - secret: Optional[bool] = None, - display_name: Optional[str] = None, - value: Optional[str] = None, - key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Optional tags that when provided can be used to filter the NamedValue list. - :paramtype tags: list[str] - :keyword secret: Determines whether the value is a secret and should be encrypted or not. - Default value is false. - :paramtype secret: bool - :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :paramtype display_name: str - :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. - :paramtype value: str - :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - super().__init__(tags=tags, secret=secret, **kwargs) - self.display_name = display_name - self.value = value - self.key_vault = key_vault - - -class NamedValueUpdateParameters(_serialization.Model): - """NamedValue update Parameters. - - :ivar tags: Optional tags that when provided can be used to filter the NamedValue list. - :vartype tags: list[str] - :ivar secret: Determines whether the value is a secret and should be encrypted or not. Default - value is false. - :vartype secret: bool - :ivar display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :vartype display_name: str - :ivar value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. - :vartype value: str - :ivar key_vault: KeyVault location details of the namedValue. - :vartype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - - _validation = { - "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, "min_length": 1}, - } - - _attribute_map = { - "tags": {"key": "properties.tags", "type": "[str]"}, - "secret": {"key": "properties.secret", "type": "bool"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "value": {"key": "properties.value", "type": "str"}, - "key_vault": {"key": "properties.keyVault", "type": "KeyVaultContractCreateProperties"}, - } - - def __init__( - self, - *, - tags: Optional[List[str]] = None, - secret: Optional[bool] = None, - display_name: Optional[str] = None, - value: Optional[str] = None, - key_vault: Optional["_models.KeyVaultContractCreateProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: Optional tags that when provided can be used to filter the NamedValue list. - :paramtype tags: list[str] - :keyword secret: Determines whether the value is a secret and should be encrypted or not. - Default value is false. - :paramtype secret: bool - :keyword display_name: Unique name of NamedValue. It may contain only letters, digits, period, - dash, and underscore characters. - :paramtype display_name: str - :keyword value: Value of the NamedValue. Can contain policy expressions. It may not be empty or - consist only of whitespace. - :paramtype value: str - :keyword key_vault: KeyVault location details of the namedValue. - :paramtype key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties - """ - super().__init__(**kwargs) - self.tags = tags - self.secret = secret - self.display_name = display_name - self.value = value - self.key_vault = key_vault - - -class NetworkStatusContract(_serialization.Model): - """Network Status details. - - All required parameters must be populated in order to send to server. - - :ivar dns_servers: Gets the list of DNS servers IPV4 addresses. Required. - :vartype dns_servers: list[str] - :ivar connectivity_status: Gets the list of Connectivity Status to the Resources on which the - service depends upon. Required. - :vartype connectivity_status: list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] - """ - - _validation = { - "dns_servers": {"required": True}, - "connectivity_status": {"required": True}, - } - - _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, - "connectivity_status": {"key": "connectivityStatus", "type": "[ConnectivityStatusContract]"}, - } - - def __init__( - self, *, dns_servers: List[str], connectivity_status: List["_models.ConnectivityStatusContract"], **kwargs: Any - ) -> None: - """ - :keyword dns_servers: Gets the list of DNS servers IPV4 addresses. Required. - :paramtype dns_servers: list[str] - :keyword connectivity_status: Gets the list of Connectivity Status to the Resources on which - the service depends upon. Required. - :paramtype connectivity_status: - list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] - """ - super().__init__(**kwargs) - self.dns_servers = dns_servers - self.connectivity_status = connectivity_status - - -class NetworkStatusContractByLocation(_serialization.Model): - """Network Status in the Location. - - :ivar location: Location of service. - :vartype location: str - :ivar network_status: Network status in Location. - :vartype network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract - """ - - _validation = { - "location": {"min_length": 1}, - } - - _attribute_map = { - "location": {"key": "location", "type": "str"}, - "network_status": {"key": "networkStatus", "type": "NetworkStatusContract"}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - network_status: Optional["_models.NetworkStatusContract"] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: Location of service. - :paramtype location: str - :keyword network_status: Network status in Location. - :paramtype network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract - """ - super().__init__(**kwargs) - self.location = location - self.network_status = network_status - - -class NotificationCollection(_serialization.Model): - """Paged Notification list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.NotificationContract] - :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": "[NotificationContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.NotificationContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.NotificationContract] - :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 NotificationContract(ProxyResource): - """Notification 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 title: Title of the Notification. - :vartype title: str - :ivar description: Description of the Notification. - :vartype description: str - :ivar recipients: Recipient Parameter values. - :vartype recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "title": {"max_length": 1000, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "title": {"key": "properties.title", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "recipients": {"key": "properties.recipients", "type": "RecipientsContractProperties"}, - } - - def __init__( - self, - *, - title: Optional[str] = None, - description: Optional[str] = None, - recipients: Optional["_models.RecipientsContractProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword title: Title of the Notification. - :paramtype title: str - :keyword description: Description of the Notification. - :paramtype description: str - :keyword recipients: Recipient Parameter values. - :paramtype recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties - """ - super().__init__(**kwargs) - self.title = title - self.description = description - self.recipients = recipients - - -class OAuth2AuthenticationSettingsContract(_serialization.Model): - """API OAuth2 Authentication settings details. - - :ivar authorization_server_id: OAuth authorization server identifier. - :vartype authorization_server_id: str - :ivar scope: operations scope. - :vartype scope: str - """ - - _attribute_map = { - "authorization_server_id": {"key": "authorizationServerId", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - } - - def __init__( - self, *, authorization_server_id: Optional[str] = None, scope: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword authorization_server_id: OAuth authorization server identifier. - :paramtype authorization_server_id: str - :keyword scope: operations scope. - :paramtype scope: str - """ - super().__init__(**kwargs) - self.authorization_server_id = authorization_server_id - self.scope = scope - - -class OpenIdAuthenticationSettingsContract(_serialization.Model): - """API OAuth2 Authentication settings details. - - :ivar openid_provider_id: OAuth authorization server identifier. - :vartype openid_provider_id: str - :ivar bearer_token_sending_methods: How to send token to the server. - :vartype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] - """ - - _attribute_map = { - "openid_provider_id": {"key": "openidProviderId", "type": "str"}, - "bearer_token_sending_methods": {"key": "bearerTokenSendingMethods", "type": "[str]"}, - } - - def __init__( - self, - *, - openid_provider_id: Optional[str] = None, - bearer_token_sending_methods: Optional[List[Union[str, "_models.BearerTokenSendingMethods"]]] = None, - **kwargs: Any - ) -> None: - """ - :keyword openid_provider_id: OAuth authorization server identifier. - :paramtype openid_provider_id: str - :keyword bearer_token_sending_methods: How to send token to the server. - :paramtype bearer_token_sending_methods: list[str or - ~azure.mgmt.apimanagement.models.BearerTokenSendingMethods] - """ - super().__init__(**kwargs) - self.openid_provider_id = openid_provider_id - self.bearer_token_sending_methods = bearer_token_sending_methods - - -class OpenIdConnectProviderCollection(_serialization.Model): - """Paged OpenIdProviders list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] - :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": "[OpenidConnectProviderContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.OpenidConnectProviderContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] - :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 OpenidConnectProviderContract(ProxyResource): - """OpenId Connect Provider 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: User-friendly OpenID Connect Provider name. - :vartype display_name: str - :ivar description: User-friendly description of OpenID Connect Provider. - :vartype description: str - :ivar metadata_endpoint: Metadata endpoint URI. - :vartype metadata_endpoint: str - :ivar client_id: Client ID of developer console which is the client application. - :vartype client_id: str - :ivar client_secret: Client Secret of developer console which is the client application. - :vartype client_secret: str - :ivar use_in_test_console: If true, the Open ID Connect provider may be used in the developer - portal test console. True by default if no value is provided. - :vartype use_in_test_console: bool - :ivar use_in_api_documentation: If true, the Open ID Connect provider will be used in the API - documentation in the developer portal. False by default if no value is provided. - :vartype use_in_api_documentation: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"max_length": 50}, - } - - _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"}, - "metadata_endpoint": {"key": "properties.metadataEndpoint", "type": "str"}, - "client_id": {"key": "properties.clientId", "type": "str"}, - "client_secret": {"key": "properties.clientSecret", "type": "str"}, - "use_in_test_console": {"key": "properties.useInTestConsole", "type": "bool"}, - "use_in_api_documentation": {"key": "properties.useInApiDocumentation", "type": "bool"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - metadata_endpoint: Optional[str] = None, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - use_in_test_console: Optional[bool] = None, - use_in_api_documentation: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: User-friendly OpenID Connect Provider name. - :paramtype display_name: str - :keyword description: User-friendly description of OpenID Connect Provider. - :paramtype description: str - :keyword metadata_endpoint: Metadata endpoint URI. - :paramtype metadata_endpoint: str - :keyword client_id: Client ID of developer console which is the client application. - :paramtype client_id: str - :keyword client_secret: Client Secret of developer console which is the client application. - :paramtype client_secret: str - :keyword use_in_test_console: If true, the Open ID Connect provider may be used in the - developer portal test console. True by default if no value is provided. - :paramtype use_in_test_console: bool - :keyword use_in_api_documentation: If true, the Open ID Connect provider will be used in the - API documentation in the developer portal. False by default if no value is provided. - :paramtype use_in_api_documentation: bool - """ - super().__init__(**kwargs) - self.display_name = display_name - self.description = description - self.metadata_endpoint = metadata_endpoint - self.client_id = client_id - self.client_secret = client_secret - self.use_in_test_console = use_in_test_console - self.use_in_api_documentation = use_in_api_documentation - - -class OpenidConnectProviderUpdateContract(_serialization.Model): - """Parameters supplied to the Update OpenID Connect Provider operation. - - :ivar display_name: User-friendly OpenID Connect Provider name. - :vartype display_name: str - :ivar description: User-friendly description of OpenID Connect Provider. - :vartype description: str - :ivar metadata_endpoint: Metadata endpoint URI. - :vartype metadata_endpoint: str - :ivar client_id: Client ID of developer console which is the client application. - :vartype client_id: str - :ivar client_secret: Client Secret of developer console which is the client application. - :vartype client_secret: str - :ivar use_in_test_console: If true, the Open ID Connect provider may be used in the developer - portal test console. True by default if no value is provided. - :vartype use_in_test_console: bool - :ivar use_in_api_documentation: If true, the Open ID Connect provider will be used in the API - documentation in the developer portal. False by default if no value is provided. - :vartype use_in_api_documentation: bool - """ - - _validation = { - "display_name": {"max_length": 50}, - } - - _attribute_map = { - "display_name": {"key": "properties.displayName", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "metadata_endpoint": {"key": "properties.metadataEndpoint", "type": "str"}, - "client_id": {"key": "properties.clientId", "type": "str"}, - "client_secret": {"key": "properties.clientSecret", "type": "str"}, - "use_in_test_console": {"key": "properties.useInTestConsole", "type": "bool"}, - "use_in_api_documentation": {"key": "properties.useInApiDocumentation", "type": "bool"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - description: Optional[str] = None, - metadata_endpoint: Optional[str] = None, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - use_in_test_console: Optional[bool] = None, - use_in_api_documentation: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: User-friendly OpenID Connect Provider name. - :paramtype display_name: str - :keyword description: User-friendly description of OpenID Connect Provider. - :paramtype description: str - :keyword metadata_endpoint: Metadata endpoint URI. - :paramtype metadata_endpoint: str - :keyword client_id: Client ID of developer console which is the client application. - :paramtype client_id: str - :keyword client_secret: Client Secret of developer console which is the client application. - :paramtype client_secret: str - :keyword use_in_test_console: If true, the Open ID Connect provider may be used in the - developer portal test console. True by default if no value is provided. - :paramtype use_in_test_console: bool - :keyword use_in_api_documentation: If true, the Open ID Connect provider will be used in the - API documentation in the developer portal. False by default if no value is provided. - :paramtype use_in_api_documentation: bool - """ - super().__init__(**kwargs) - self.display_name = display_name - self.description = description - self.metadata_endpoint = metadata_endpoint - self.client_id = client_id - self.client_secret = client_secret - self.use_in_test_console = use_in_test_console - self.use_in_api_documentation = use_in_api_documentation - - -class Operation(_serialization.Model): - """REST API operation. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar display: The object that describes the operation. - :vartype display: ~azure.mgmt.apimanagement.models.OperationDisplay - :ivar origin: The operation origin. - :vartype origin: str - :ivar properties: The operation properties. - :vartype properties: JSON - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "properties": {"key": "properties", "type": "object"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["_models.OperationDisplay"] = None, - origin: Optional[str] = None, - properties: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Operation name: {provider}/{resource}/{operation}. - :paramtype name: str - :keyword display: The object that describes the operation. - :paramtype display: ~azure.mgmt.apimanagement.models.OperationDisplay - :keyword origin: The operation origin. - :paramtype origin: str - :keyword properties: The operation properties. - :paramtype properties: JSON - """ - super().__init__(**kwargs) - self.name = name - self.display = display - self.origin = origin - self.properties = properties - - -class OperationCollection(_serialization.Model): - """Paged Operation list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.OperationContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[OperationContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class OperationContract(ProxyResource): - """API Operation 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 template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :ivar description: Description of the operation. May include HTML formatting tags. - :vartype description: str - :ivar request: An entity containing request details. - :vartype request: ~azure.mgmt.apimanagement.models.RequestContract - :ivar responses: Array of Operation responses. - :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :ivar policies: Operation Policies. - :vartype policies: str - :ivar display_name: Operation Name. - :vartype display_name: str - :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not - limited by only them. - :vartype method: str - :ivar url_template: Relative URL template identifying the target resource for this operation. - May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :vartype url_template: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "description": {"max_length": 1000}, - "display_name": {"max_length": 300, "min_length": 1}, - "url_template": {"max_length": 1000, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "template_parameters": {"key": "properties.templateParameters", "type": "[ParameterContract]"}, - "description": {"key": "properties.description", "type": "str"}, - "request": {"key": "properties.request", "type": "RequestContract"}, - "responses": {"key": "properties.responses", "type": "[ResponseContract]"}, - "policies": {"key": "properties.policies", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "method": {"key": "properties.method", "type": "str"}, - "url_template": {"key": "properties.urlTemplate", "type": "str"}, - } - - def __init__( - self, - *, - template_parameters: Optional[List["_models.ParameterContract"]] = None, - description: Optional[str] = None, - request: Optional["_models.RequestContract"] = None, - responses: Optional[List["_models.ResponseContract"]] = None, - policies: Optional[str] = None, - display_name: Optional[str] = None, - method: Optional[str] = None, - url_template: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :keyword description: Description of the operation. May include HTML formatting tags. - :paramtype description: str - :keyword request: An entity containing request details. - :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract - :keyword responses: Array of Operation responses. - :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :keyword policies: Operation Policies. - :paramtype policies: str - :keyword display_name: Operation Name. - :paramtype display_name: str - :keyword method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but - not limited by only them. - :paramtype method: str - :keyword url_template: Relative URL template identifying the target resource for this - operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :paramtype url_template: str - """ - super().__init__(**kwargs) - self.template_parameters = template_parameters - self.description = description - self.request = request - self.responses = responses - self.policies = policies - self.display_name = display_name - self.method = method - self.url_template = url_template - - -class OperationEntityBaseContract(_serialization.Model): - """API Operation Entity Base Contract details. - - :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :ivar description: Description of the operation. May include HTML formatting tags. - :vartype description: str - :ivar request: An entity containing request details. - :vartype request: ~azure.mgmt.apimanagement.models.RequestContract - :ivar responses: Array of Operation responses. - :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :ivar policies: Operation Policies. - :vartype policies: str - """ - - _validation = { - "description": {"max_length": 1000}, - } - - _attribute_map = { - "template_parameters": {"key": "templateParameters", "type": "[ParameterContract]"}, - "description": {"key": "description", "type": "str"}, - "request": {"key": "request", "type": "RequestContract"}, - "responses": {"key": "responses", "type": "[ResponseContract]"}, - "policies": {"key": "policies", "type": "str"}, - } - - def __init__( - self, - *, - template_parameters: Optional[List["_models.ParameterContract"]] = None, - description: Optional[str] = None, - request: Optional["_models.RequestContract"] = None, - responses: Optional[List["_models.ResponseContract"]] = None, - policies: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :keyword description: Description of the operation. May include HTML formatting tags. - :paramtype description: str - :keyword request: An entity containing request details. - :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract - :keyword responses: Array of Operation responses. - :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :keyword policies: Operation Policies. - :paramtype policies: str - """ - super().__init__(**kwargs) - self.template_parameters = template_parameters - self.description = description - self.request = request - self.responses = responses - self.policies = policies - - -class OperationContractProperties(OperationEntityBaseContract): - """Operation Contract Properties. - - All required parameters must be populated in order to send to server. - - :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :ivar description: Description of the operation. May include HTML formatting tags. - :vartype description: str - :ivar request: An entity containing request details. - :vartype request: ~azure.mgmt.apimanagement.models.RequestContract - :ivar responses: Array of Operation responses. - :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :ivar policies: Operation Policies. - :vartype policies: str - :ivar display_name: Operation Name. Required. - :vartype display_name: str - :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not - limited by only them. Required. - :vartype method: str - :ivar url_template: Relative URL template identifying the target resource for this operation. - May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. Required. - :vartype url_template: str - """ - - _validation = { - "description": {"max_length": 1000}, - "display_name": {"required": True, "max_length": 300, "min_length": 1}, - "method": {"required": True}, - "url_template": {"required": True, "max_length": 1000, "min_length": 1}, - } - - _attribute_map = { - "template_parameters": {"key": "templateParameters", "type": "[ParameterContract]"}, - "description": {"key": "description", "type": "str"}, - "request": {"key": "request", "type": "RequestContract"}, - "responses": {"key": "responses", "type": "[ResponseContract]"}, - "policies": {"key": "policies", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "method": {"key": "method", "type": "str"}, - "url_template": {"key": "urlTemplate", "type": "str"}, - } - - def __init__( - self, - *, - display_name: str, - method: str, - url_template: str, - template_parameters: Optional[List["_models.ParameterContract"]] = None, - description: Optional[str] = None, - request: Optional["_models.RequestContract"] = None, - responses: Optional[List["_models.ResponseContract"]] = None, - policies: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :keyword description: Description of the operation. May include HTML formatting tags. - :paramtype description: str - :keyword request: An entity containing request details. - :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract - :keyword responses: Array of Operation responses. - :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :keyword policies: Operation Policies. - :paramtype policies: str - :keyword display_name: Operation Name. Required. - :paramtype display_name: str - :keyword method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but - not limited by only them. Required. - :paramtype method: str - :keyword url_template: Relative URL template identifying the target resource for this - operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - Required. - :paramtype url_template: str - """ - super().__init__( - template_parameters=template_parameters, - description=description, - request=request, - responses=responses, - policies=policies, - **kwargs - ) - self.display_name = display_name - self.method = method - self.url_template = url_template - - -class OperationDisplay(_serialization.Model): - """The object that describes the operation. - - :ivar provider: Friendly name of the resource provider. - :vartype provider: str - :ivar operation: Operation type: read, write, delete, listKeys/action, etc. - :vartype operation: str - :ivar resource: Resource type on which the operation is performed. - :vartype resource: str - :ivar description: Friendly name of the operation. - :vartype description: str - """ - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - provider: Optional[str] = None, - operation: Optional[str] = None, - resource: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provider: Friendly name of the resource provider. - :paramtype provider: str - :keyword operation: Operation type: read, write, delete, listKeys/action, etc. - :paramtype operation: str - :keyword resource: Resource type on which the operation is performed. - :paramtype resource: str - :keyword description: Friendly name of the operation. - :paramtype description: str - """ - super().__init__(**kwargs) - self.provider = provider - self.operation = operation - self.resource = resource - self.description = description - - -class OperationListResult(_serialization.Model): - """Result of the request to list REST API operations. It contains a list of operations and a URL - nextLink to get the next set of results. - - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.apimanagement.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: List of operations supported by the resource provider. - :paramtype value: list[~azure.mgmt.apimanagement.models.Operation] - :keyword next_link: URL to get the next set of operation list results if there are any. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class OperationResultContract(ProxyResource): - """Long Running Git Operation Results. - - 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 id_properties_id: Operation result identifier. - :vartype id_properties_id: str - :ivar status: Status of an async operation. Known values are: "Started", "InProgress", - "Succeeded", and "Failed". - :vartype status: str or ~azure.mgmt.apimanagement.models.AsyncOperationStatus - :ivar started: Start time of an async operation. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype started: ~datetime.datetime - :ivar updated: Last update time of an async operation. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype updated: ~datetime.datetime - :ivar result_info: Optional result info. - :vartype result_info: str - :ivar error: Error Body Contract. - :vartype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody - :ivar action_log: This property if only provided as part of the TenantConfiguration_Validate - operation. It contains the log the entities which will be updated/created/deleted as part of - the TenantConfiguration_Deploy operation. - :vartype action_log: list[~azure.mgmt.apimanagement.models.OperationResultLogItemContract] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "action_log": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "id_properties_id": {"key": "properties.id", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "started": {"key": "properties.started", "type": "iso-8601"}, - "updated": {"key": "properties.updated", "type": "iso-8601"}, - "result_info": {"key": "properties.resultInfo", "type": "str"}, - "error": {"key": "properties.error", "type": "ErrorResponseBody"}, - "action_log": {"key": "properties.actionLog", "type": "[OperationResultLogItemContract]"}, - } - - def __init__( - self, - *, - id_properties_id: Optional[str] = None, - status: Optional[Union[str, "_models.AsyncOperationStatus"]] = None, - started: Optional[datetime.datetime] = None, - updated: Optional[datetime.datetime] = None, - result_info: Optional[str] = None, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id_properties_id: Operation result identifier. - :paramtype id_properties_id: str - :keyword status: Status of an async operation. Known values are: "Started", "InProgress", - "Succeeded", and "Failed". - :paramtype status: str or ~azure.mgmt.apimanagement.models.AsyncOperationStatus - :keyword started: Start time of an async operation. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype started: ~datetime.datetime - :keyword updated: Last update time of an async operation. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype updated: ~datetime.datetime - :keyword result_info: Optional result info. - :paramtype result_info: str - :keyword error: Error Body Contract. - :paramtype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody - """ - super().__init__(**kwargs) - self.id_properties_id = id_properties_id - self.status = status - self.started = started - self.updated = updated - self.result_info = result_info - self.error = error - self.action_log = None - - -class OperationResultLogItemContract(_serialization.Model): - """Log of the entity being created, updated or deleted. - - :ivar object_type: The type of entity contract. - :vartype object_type: str - :ivar action: Action like create/update/delete. - :vartype action: str - :ivar object_key: Identifier of the entity being created/updated/deleted. - :vartype object_key: str - """ - - _attribute_map = { - "object_type": {"key": "objectType", "type": "str"}, - "action": {"key": "action", "type": "str"}, - "object_key": {"key": "objectKey", "type": "str"}, - } - - def __init__( - self, - *, - object_type: Optional[str] = None, - action: Optional[str] = None, - object_key: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword object_type: The type of entity contract. - :paramtype object_type: str - :keyword action: Action like create/update/delete. - :paramtype action: str - :keyword object_key: Identifier of the entity being created/updated/deleted. - :paramtype object_key: str - """ - super().__init__(**kwargs) - self.object_type = object_type - self.action = action - 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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Identifier of the operation in form /operations/{operationId}. - :vartype id: str - :ivar name: Operation name. - :vartype name: str - :ivar api_name: API Name. - :vartype api_name: str - :ivar api_revision: API Revision. - :vartype api_revision: str - :ivar api_version: API Version. - :vartype api_version: str - :ivar description: Operation Description. - :vartype description: str - :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not - limited by only them. - :vartype method: str - :ivar url_template: Relative URL template identifying the target resource for this operation. - May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :vartype url_template: str - """ - - _validation = { - "name": {"readonly": True}, - "api_name": {"readonly": True}, - "api_revision": {"readonly": True}, - "api_version": {"readonly": True}, - "description": {"readonly": True}, - "method": {"readonly": True}, - "url_template": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "api_name": {"key": "apiName", "type": "str"}, - "api_revision": {"key": "apiRevision", "type": "str"}, - "api_version": {"key": "apiVersion", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "method": {"key": "method", "type": "str"}, - "url_template": {"key": "urlTemplate", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: Identifier of the operation in form /operations/{operationId}. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - self.name = None - self.api_name = None - self.api_revision = None - self.api_version = None - self.description = None - self.method = None - self.url_template = None - - -class OperationUpdateContract(_serialization.Model): - """API Operation Update Contract details. - - :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :ivar description: Description of the operation. May include HTML formatting tags. - :vartype description: str - :ivar request: An entity containing request details. - :vartype request: ~azure.mgmt.apimanagement.models.RequestContract - :ivar responses: Array of Operation responses. - :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :ivar policies: Operation Policies. - :vartype policies: str - :ivar display_name: Operation Name. - :vartype display_name: str - :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not - limited by only them. - :vartype method: str - :ivar url_template: Relative URL template identifying the target resource for this operation. - May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :vartype url_template: str - """ - - _validation = { - "description": {"max_length": 1000}, - "display_name": {"max_length": 300, "min_length": 1}, - "url_template": {"max_length": 1000, "min_length": 1}, - } - - _attribute_map = { - "template_parameters": {"key": "properties.templateParameters", "type": "[ParameterContract]"}, - "description": {"key": "properties.description", "type": "str"}, - "request": {"key": "properties.request", "type": "RequestContract"}, - "responses": {"key": "properties.responses", "type": "[ResponseContract]"}, - "policies": {"key": "properties.policies", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "method": {"key": "properties.method", "type": "str"}, - "url_template": {"key": "properties.urlTemplate", "type": "str"}, - } - - def __init__( - self, - *, - template_parameters: Optional[List["_models.ParameterContract"]] = None, - description: Optional[str] = None, - request: Optional["_models.RequestContract"] = None, - responses: Optional[List["_models.ResponseContract"]] = None, - policies: Optional[str] = None, - display_name: Optional[str] = None, - method: Optional[str] = None, - url_template: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :keyword description: Description of the operation. May include HTML formatting tags. - :paramtype description: str - :keyword request: An entity containing request details. - :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract - :keyword responses: Array of Operation responses. - :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :keyword policies: Operation Policies. - :paramtype policies: str - :keyword display_name: Operation Name. - :paramtype display_name: str - :keyword method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but - not limited by only them. - :paramtype method: str - :keyword url_template: Relative URL template identifying the target resource for this - operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :paramtype url_template: str - """ - super().__init__(**kwargs) - self.template_parameters = template_parameters - self.description = description - self.request = request - self.responses = responses - self.policies = policies - self.display_name = display_name - self.method = method - self.url_template = url_template - - -class OperationUpdateContractProperties(OperationEntityBaseContract): - """Operation Update Contract Properties. - - :ivar template_parameters: Collection of URL template parameters. - :vartype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :ivar description: Description of the operation. May include HTML formatting tags. - :vartype description: str - :ivar request: An entity containing request details. - :vartype request: ~azure.mgmt.apimanagement.models.RequestContract - :ivar responses: Array of Operation responses. - :vartype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :ivar policies: Operation Policies. - :vartype policies: str - :ivar display_name: Operation Name. - :vartype display_name: str - :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not - limited by only them. - :vartype method: str - :ivar url_template: Relative URL template identifying the target resource for this operation. - May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :vartype url_template: str - """ - - _validation = { - "description": {"max_length": 1000}, - "display_name": {"max_length": 300, "min_length": 1}, - "url_template": {"max_length": 1000, "min_length": 1}, - } - - _attribute_map = { - "template_parameters": {"key": "templateParameters", "type": "[ParameterContract]"}, - "description": {"key": "description", "type": "str"}, - "request": {"key": "request", "type": "RequestContract"}, - "responses": {"key": "responses", "type": "[ResponseContract]"}, - "policies": {"key": "policies", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - "method": {"key": "method", "type": "str"}, - "url_template": {"key": "urlTemplate", "type": "str"}, - } - - def __init__( - self, - *, - template_parameters: Optional[List["_models.ParameterContract"]] = None, - description: Optional[str] = None, - request: Optional["_models.RequestContract"] = None, - responses: Optional[List["_models.ResponseContract"]] = None, - policies: Optional[str] = None, - display_name: Optional[str] = None, - method: Optional[str] = None, - url_template: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword template_parameters: Collection of URL template parameters. - :paramtype template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :keyword description: Description of the operation. May include HTML formatting tags. - :paramtype description: str - :keyword request: An entity containing request details. - :paramtype request: ~azure.mgmt.apimanagement.models.RequestContract - :keyword responses: Array of Operation responses. - :paramtype responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :keyword policies: Operation Policies. - :paramtype policies: str - :keyword display_name: Operation Name. - :paramtype display_name: str - :keyword method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but - not limited by only them. - :paramtype method: str - :keyword url_template: Relative URL template identifying the target resource for this - operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. - :paramtype url_template: str - """ - super().__init__( - template_parameters=template_parameters, - description=description, - request=request, - responses=responses, - policies=policies, - **kwargs - ) - self.display_name = display_name - self.method = method - self.url_template = url_template - - -class OutboundEnvironmentEndpoint(_serialization.Model): - """Endpoints accessed for a common purpose that the Api Management Service requires outbound - network access to. - - :ivar category: The type of service accessed by the Api Management Service, e.g., Azure - Storage, Azure SQL Database, and Azure Active Directory. - :vartype category: str - :ivar endpoints: The endpoints that the Api Management Service reaches the service at. - :vartype endpoints: list[~azure.mgmt.apimanagement.models.EndpointDependency] - """ - - _attribute_map = { - "category": {"key": "category", "type": "str"}, - "endpoints": {"key": "endpoints", "type": "[EndpointDependency]"}, - } - - def __init__( - self, - *, - category: Optional[str] = None, - endpoints: Optional[List["_models.EndpointDependency"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword category: The type of service accessed by the Api Management Service, e.g., Azure - Storage, Azure SQL Database, and Azure Active Directory. - :paramtype category: str - :keyword endpoints: The endpoints that the Api Management Service reaches the service at. - :paramtype endpoints: list[~azure.mgmt.apimanagement.models.EndpointDependency] - """ - super().__init__(**kwargs) - self.category = category - self.endpoints = endpoints - - -class OutboundEnvironmentEndpointList(_serialization.Model): - """Collection of Outbound Environment Endpoints. - - 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 value: Collection of resources. Required. - :vartype value: list[~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpoint] - :ivar next_link: Link to next page of resources. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[OutboundEnvironmentEndpoint]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: List["_models.OutboundEnvironmentEndpoint"], **kwargs: Any) -> None: - """ - :keyword value: Collection of resources. Required. - :paramtype value: list[~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpoint] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class ParameterContract(_serialization.Model): - """Operation parameters details. - - All required parameters must be populated in order to send to server. - - :ivar name: Parameter name. Required. - :vartype name: str - :ivar description: Parameter description. - :vartype description: str - :ivar type: Parameter type. Required. - :vartype type: str - :ivar default_value: Default parameter value. - :vartype default_value: str - :ivar required: Specifies whether parameter is required or not. - :vartype required: bool - :ivar values: Parameter values. - :vartype values: list[str] - :ivar schema_id: Schema identifier. - :vartype schema_id: str - :ivar type_name: Type name defined by the schema. - :vartype type_name: str - :ivar examples: Exampled defined for the parameter. - :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] - """ - - _validation = { - "name": {"required": True}, - "type": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "required": {"key": "required", "type": "bool"}, - "values": {"key": "values", "type": "[str]"}, - "schema_id": {"key": "schemaId", "type": "str"}, - "type_name": {"key": "typeName", "type": "str"}, - "examples": {"key": "examples", "type": "{ParameterExampleContract}"}, - } - - def __init__( - self, - *, - name: str, - type: str, - description: Optional[str] = None, - default_value: Optional[str] = None, - required: Optional[bool] = None, - values: Optional[List[str]] = None, - schema_id: Optional[str] = None, - type_name: Optional[str] = None, - examples: Optional[Dict[str, "_models.ParameterExampleContract"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Parameter name. Required. - :paramtype name: str - :keyword description: Parameter description. - :paramtype description: str - :keyword type: Parameter type. Required. - :paramtype type: str - :keyword default_value: Default parameter value. - :paramtype default_value: str - :keyword required: Specifies whether parameter is required or not. - :paramtype required: bool - :keyword values: Parameter values. - :paramtype values: list[str] - :keyword schema_id: Schema identifier. - :paramtype schema_id: str - :keyword type_name: Type name defined by the schema. - :paramtype type_name: str - :keyword examples: Exampled defined for the parameter. - :paramtype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] - """ - super().__init__(**kwargs) - self.name = name - self.description = description - self.type = type - self.default_value = default_value - self.required = required - self.values = values - self.schema_id = schema_id - self.type_name = type_name - self.examples = examples - - -class ParameterExampleContract(_serialization.Model): - """Parameter example. - - :ivar summary: Short description for the example. - :vartype summary: str - :ivar description: Long description for the example. - :vartype description: str - :ivar value: Example value. May be a primitive value, or an object. - :vartype value: any - :ivar external_value: A URL that points to the literal example. - :vartype external_value: str - """ - - _attribute_map = { - "summary": {"key": "summary", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "value": {"key": "value", "type": "object"}, - "external_value": {"key": "externalValue", "type": "str"}, - } - - def __init__( - self, - *, - summary: Optional[str] = None, - description: Optional[str] = None, - value: Optional[Any] = None, - external_value: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword summary: Short description for the example. - :paramtype summary: str - :keyword description: Long description for the example. - :paramtype description: str - :keyword value: Example value. May be a primitive value, or an object. - :paramtype value: any - :keyword external_value: A URL that points to the literal example. - :paramtype external_value: str - """ - super().__init__(**kwargs) - self.summary = summary - self.description = description - self.value = value - self.external_value = external_value - - -class PipelineDiagnosticSettings(_serialization.Model): - """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. - - :ivar request: Diagnostic settings for request. - :vartype request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic - :ivar response: Diagnostic settings for response. - :vartype response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic - """ - - _attribute_map = { - "request": {"key": "request", "type": "HttpMessageDiagnostic"}, - "response": {"key": "response", "type": "HttpMessageDiagnostic"}, - } - - def __init__( - self, - *, - request: Optional["_models.HttpMessageDiagnostic"] = None, - response: Optional["_models.HttpMessageDiagnostic"] = None, - **kwargs: Any - ) -> None: - """ - :keyword request: Diagnostic settings for request. - :paramtype request: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic - :keyword response: Diagnostic settings for response. - :paramtype response: ~azure.mgmt.apimanagement.models.HttpMessageDiagnostic - """ - super().__init__(**kwargs) - self.request = request - self.response = response - - -class PolicyCollection(_serialization.Model): - """The response of the list policy operation. - - :ivar value: Policy Contract value. - :vartype value: list[~azure.mgmt.apimanagement.models.PolicyContract] - :ivar count: Total record count number. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PolicyContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.PolicyContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Policy Contract value. - :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyContract] - :keyword count: Total record count number. - :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 PolicyContract(ProxyResource): - """Policy 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 as defined by the format. - :vartype value: str - :ivar format: Format of the policyContent. Known values are: "xml", "xml-link", "rawxml", and - "rawxml-link". - :vartype format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat - """ - - _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"}, - "value": {"key": "properties.value", "type": "str"}, - "format": {"key": "properties.format", "type": "str"}, - } - - def __init__( - self, *, value: Optional[str] = None, format: Union[str, "_models.PolicyContentFormat"] = "xml", **kwargs: Any - ) -> None: - """ - :keyword value: Contents of the Policy as defined by the format. - :paramtype value: str - :keyword format: Format of the policyContent. Known values are: "xml", "xml-link", "rawxml", - and "rawxml-link". - :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat - """ - super().__init__(**kwargs) - self.value = value - self.format = format - - -class PolicyDescriptionCollection(_serialization.Model): - """Descriptions of API Management policies. - - :ivar value: Descriptions of API Management policies. - :vartype value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] - :ivar count: Total record count number. - :vartype count: int - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PolicyDescriptionContract]"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.PolicyDescriptionContract"]] = None, - count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Descriptions of API Management policies. - :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] - :keyword count: Total record count number. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = value - self.count = count - - -class PolicyDescriptionContract(ProxyResource): - """Policy description 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 description: Policy description. - :vartype description: str - :ivar scope: Binary OR value of the Snippet scope. - :vartype scope: int - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "description": {"readonly": True}, - "scope": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "scope": {"key": "properties.scope", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.description = None - self.scope = None - - -class PolicyFragmentCollection(_serialization.Model): - """The response of the get policy fragments operation. - - :ivar value: Policy fragment contract value. - :vartype value: list[~azure.mgmt.apimanagement.models.PolicyFragmentContract] - :ivar count: Total record count number. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PolicyFragmentContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.PolicyFragmentContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Policy fragment contract value. - :paramtype value: list[~azure.mgmt.apimanagement.models.PolicyFragmentContract] - :keyword count: Total record count number. - :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 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 PolicyWithComplianceContract(ProxyResource): - """Policy 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 PortalConfigCollection(_serialization.Model): - """The collection of the developer portal configurations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The developer portal configurations. - :vartype value: list[~azure.mgmt.apimanagement.models.PortalConfigContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PortalConfigContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, value: Optional[List["_models.PortalConfigContract"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The developer portal configurations. - :paramtype value: list[~azure.mgmt.apimanagement.models.PortalConfigContract] - """ - super().__init__(**kwargs) - self.value = value - self.next_link = None - - -class PortalConfigContract(ProxyResource): - """The developer portal configuration contract. - - 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 enable_basic_auth: Enable or disable Basic authentication method. - :vartype enable_basic_auth: bool - :ivar signin: - :vartype signin: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignin - :ivar signup: - :vartype signup: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignup - :ivar delegation: The developer portal delegation settings. - :vartype delegation: ~azure.mgmt.apimanagement.models.PortalConfigDelegationProperties - :ivar cors: The developer portal Cross-Origin Resource Sharing (CORS) settings. - :vartype cors: ~azure.mgmt.apimanagement.models.PortalConfigCorsProperties - :ivar csp: The developer portal Content Security Policy (CSP) settings. - :vartype csp: ~azure.mgmt.apimanagement.models.PortalConfigCspProperties - """ - - _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"}, - "enable_basic_auth": {"key": "properties.enableBasicAuth", "type": "bool"}, - "signin": {"key": "properties.signin", "type": "PortalConfigPropertiesSignin"}, - "signup": {"key": "properties.signup", "type": "PortalConfigPropertiesSignup"}, - "delegation": {"key": "properties.delegation", "type": "PortalConfigDelegationProperties"}, - "cors": {"key": "properties.cors", "type": "PortalConfigCorsProperties"}, - "csp": {"key": "properties.csp", "type": "PortalConfigCspProperties"}, - } - - def __init__( - self, - *, - enable_basic_auth: bool = True, - signin: Optional["_models.PortalConfigPropertiesSignin"] = None, - signup: Optional["_models.PortalConfigPropertiesSignup"] = None, - delegation: Optional["_models.PortalConfigDelegationProperties"] = None, - cors: Optional["_models.PortalConfigCorsProperties"] = None, - csp: Optional["_models.PortalConfigCspProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enable_basic_auth: Enable or disable Basic authentication method. - :paramtype enable_basic_auth: bool - :keyword signin: - :paramtype signin: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignin - :keyword signup: - :paramtype signup: ~azure.mgmt.apimanagement.models.PortalConfigPropertiesSignup - :keyword delegation: The developer portal delegation settings. - :paramtype delegation: ~azure.mgmt.apimanagement.models.PortalConfigDelegationProperties - :keyword cors: The developer portal Cross-Origin Resource Sharing (CORS) settings. - :paramtype cors: ~azure.mgmt.apimanagement.models.PortalConfigCorsProperties - :keyword csp: The developer portal Content Security Policy (CSP) settings. - :paramtype csp: ~azure.mgmt.apimanagement.models.PortalConfigCspProperties - """ - super().__init__(**kwargs) - self.enable_basic_auth = enable_basic_auth - self.signin = signin - self.signup = signup - self.delegation = delegation - self.cors = cors - self.csp = csp - - -class PortalConfigCorsProperties(_serialization.Model): - """The developer portal Cross-Origin Resource Sharing (CORS) settings. - - :ivar allowed_origins: Allowed origins, e.g. ``https://trusted.com``. - :vartype allowed_origins: list[str] - """ - - _attribute_map = { - "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, - } - - def __init__(self, *, allowed_origins: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword allowed_origins: Allowed origins, e.g. ``https://trusted.com``. - :paramtype allowed_origins: list[str] - """ - super().__init__(**kwargs) - self.allowed_origins = allowed_origins - - -class PortalConfigCspProperties(_serialization.Model): - """The developer portal Content Security Policy (CSP) settings. - - :ivar mode: The mode of the developer portal Content Security Policy (CSP). Known values are: - "enabled", "disabled", and "reportOnly". - :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``\\ , - ``https://``. - :vartype allowed_sources: list[str] - """ - - _attribute_map = { - "mode": {"key": "mode", "type": "str"}, - "report_uri": {"key": "reportUri", "type": "[str]"}, - "allowed_sources": {"key": "allowedSources", "type": "[str]"}, - } - - def __init__( - self, - *, - mode: Union[str, "_models.PortalSettingsCspMode"] = "disabled", - report_uri: Optional[List[str]] = None, - allowed_sources: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword mode: The mode of the developer portal Content Security Policy (CSP). Known values - are: "enabled", "disabled", and "reportOnly". - :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``\\ , - ``https://``. - :paramtype allowed_sources: list[str] - """ - super().__init__(**kwargs) - self.mode = mode - self.report_uri = report_uri - self.allowed_sources = allowed_sources - - -class PortalConfigDelegationProperties(_serialization.Model): - """PortalConfigDelegationProperties. - - :ivar delegate_registration: Enable or disable delegation for user registration. - :vartype delegate_registration: bool - :ivar delegate_subscription: Enable or disable delegation for product subscriptions. - :vartype delegate_subscription: bool - :ivar delegation_url: A delegation endpoint URL. - :vartype delegation_url: str - :ivar validation_key: A base64-encoded validation key to ensure requests originate from Azure - API Management service. - :vartype validation_key: str - """ - - _attribute_map = { - "delegate_registration": {"key": "delegateRegistration", "type": "bool"}, - "delegate_subscription": {"key": "delegateSubscription", "type": "bool"}, - "delegation_url": {"key": "delegationUrl", "type": "str"}, - "validation_key": {"key": "validationKey", "type": "str"}, - } - - def __init__( - self, - *, - delegate_registration: bool = False, - delegate_subscription: bool = False, - delegation_url: Optional[str] = None, - validation_key: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword delegate_registration: Enable or disable delegation for user registration. - :paramtype delegate_registration: bool - :keyword delegate_subscription: Enable or disable delegation for product subscriptions. - :paramtype delegate_subscription: bool - :keyword delegation_url: A delegation endpoint URL. - :paramtype delegation_url: str - :keyword validation_key: A base64-encoded validation key to ensure requests originate from - Azure API Management service. - :paramtype validation_key: str - """ - super().__init__(**kwargs) - self.delegate_registration = delegate_registration - self.delegate_subscription = delegate_subscription - self.delegation_url = delegation_url - self.validation_key = validation_key - - -class PortalConfigPropertiesSignin(_serialization.Model): - """PortalConfigPropertiesSignin. - - :ivar require: Redirect anonymous users to the sign-in page. - :vartype require: bool - """ - - _attribute_map = { - "require": {"key": "require", "type": "bool"}, - } - - def __init__(self, *, require: bool = False, **kwargs: Any) -> None: - """ - :keyword require: Redirect anonymous users to the sign-in page. - :paramtype require: bool - """ - super().__init__(**kwargs) - self.require = require - - -class PortalConfigPropertiesSignup(_serialization.Model): - """PortalConfigPropertiesSignup. - - :ivar terms_of_service: Terms of service settings. - :vartype terms_of_service: - ~azure.mgmt.apimanagement.models.PortalConfigTermsOfServiceProperties - """ - - _attribute_map = { - "terms_of_service": {"key": "termsOfService", "type": "PortalConfigTermsOfServiceProperties"}, - } - - def __init__( - self, *, terms_of_service: Optional["_models.PortalConfigTermsOfServiceProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword terms_of_service: Terms of service settings. - :paramtype terms_of_service: - ~azure.mgmt.apimanagement.models.PortalConfigTermsOfServiceProperties - """ - super().__init__(**kwargs) - self.terms_of_service = terms_of_service - - -class PortalConfigTermsOfServiceProperties(_serialization.Model): - """Terms of service contract properties. - - :ivar text: A terms of service text. - :vartype text: str - :ivar require_consent: Ask user for consent to the terms of service. - :vartype require_consent: bool - """ - - _attribute_map = { - "text": {"key": "text", "type": "str"}, - "require_consent": {"key": "requireConsent", "type": "bool"}, - } - - def __init__(self, *, text: Optional[str] = None, require_consent: bool = False, **kwargs: Any) -> None: - """ - :keyword text: A terms of service text. - :paramtype text: str - :keyword require_consent: Ask user for consent to the terms of service. - :paramtype require_consent: bool - """ - super().__init__(**kwargs) - self.text = text - self.require_consent = require_consent - - -class PortalDelegationSettings(ProxyResource): - """Delegation settings for a developer portal. - - 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 url: A delegation Url. - :vartype url: str - :ivar validation_key: A base64-encoded validation key to validate, that a request is coming - from Azure API Management. - :vartype validation_key: str - :ivar subscriptions: Subscriptions delegation settings. - :vartype subscriptions: - ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties - :ivar user_registration: User registration delegation settings. - :vartype user_registration: - ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties - """ - - _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"}, - "url": {"key": "properties.url", "type": "str"}, - "validation_key": {"key": "properties.validationKey", "type": "str"}, - "subscriptions": {"key": "properties.subscriptions", "type": "SubscriptionsDelegationSettingsProperties"}, - "user_registration": {"key": "properties.userRegistration", "type": "RegistrationDelegationSettingsProperties"}, - } - - def __init__( - self, - *, - url: Optional[str] = None, - validation_key: Optional[str] = None, - subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = None, - user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword url: A delegation Url. - :paramtype url: str - :keyword validation_key: A base64-encoded validation key to validate, that a request is coming - from Azure API Management. - :paramtype validation_key: str - :keyword subscriptions: Subscriptions delegation settings. - :paramtype subscriptions: - ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties - :keyword user_registration: User registration delegation settings. - :paramtype user_registration: - ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties - """ - super().__init__(**kwargs) - self.url = url - self.validation_key = validation_key - self.subscriptions = subscriptions - self.user_registration = user_registration - - -class PortalRevisionCollection(_serialization.Model): - """Paged list of portal revisions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Collection of portal revisions. - :vartype value: list[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :ivar next_link: Next page link, if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PortalRevisionContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class PortalRevisionContract(ProxyResource): - """Portal Revision's 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 description: Portal revision description. - :vartype description: str - :ivar status_details: Portal revision publishing status details. - :vartype status_details: str - :ivar status: Status of the portal's revision. Known values are: "pending", "publishing", - "completed", and "failed". - :vartype status: str or ~azure.mgmt.apimanagement.models.PortalRevisionStatus - :ivar is_current: Indicates if the portal's revision is public. - :vartype is_current: bool - :ivar created_date_time: Portal's revision creation date and time. - :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 = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "description": {"max_length": 2000}, - "status_details": {"readonly": True, "max_length": 2000}, - "status": {"readonly": True}, - "created_date_time": {"readonly": True}, - "updated_date_time": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "status_details": {"key": "properties.statusDetails", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "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: - """ - :keyword description: Portal revision description. - :paramtype description: str - :keyword is_current: Indicates if the portal's revision is public. - :paramtype is_current: bool - """ - super().__init__(**kwargs) - self.description = description - self.status_details = None - self.status = None - self.is_current = is_current - self.created_date_time = None - self.updated_date_time = None - self.provisioning_state = None - - -class PortalSettingsCollection(_serialization.Model): - """Descriptions of API Management policies. - - :ivar value: Descriptions of API Management policies. - :vartype value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] - :ivar count: Total record count number. - :vartype count: int - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PortalSettingsContract]"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.PortalSettingsContract"]] = None, - count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Descriptions of API Management policies. - :paramtype value: list[~azure.mgmt.apimanagement.models.PortalSettingsContract] - :keyword count: Total record count number. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = value - self.count = count - - -class PortalSettingsContract(ProxyResource): - """Portal Settings for the Developer Portal. - - 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 url: A delegation Url. - :vartype url: str - :ivar validation_key: A base64-encoded validation key to validate, that a request is coming - from Azure API Management. - :vartype validation_key: str - :ivar subscriptions: Subscriptions delegation settings. - :vartype subscriptions: - ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties - :ivar user_registration: User registration delegation settings. - :vartype user_registration: - ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties - :ivar enabled: Redirect Anonymous users to the Sign-In page. - :vartype enabled: bool - :ivar terms_of_service: Terms of service contract properties. - :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties - """ - - _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"}, - "url": {"key": "properties.url", "type": "str"}, - "validation_key": {"key": "properties.validationKey", "type": "str"}, - "subscriptions": {"key": "properties.subscriptions", "type": "SubscriptionsDelegationSettingsProperties"}, - "user_registration": {"key": "properties.userRegistration", "type": "RegistrationDelegationSettingsProperties"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "terms_of_service": {"key": "properties.termsOfService", "type": "TermsOfServiceProperties"}, - } - - def __init__( - self, - *, - url: Optional[str] = None, - validation_key: Optional[str] = None, - subscriptions: Optional["_models.SubscriptionsDelegationSettingsProperties"] = None, - user_registration: Optional["_models.RegistrationDelegationSettingsProperties"] = None, - enabled: Optional[bool] = None, - terms_of_service: Optional["_models.TermsOfServiceProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword url: A delegation Url. - :paramtype url: str - :keyword validation_key: A base64-encoded validation key to validate, that a request is coming - from Azure API Management. - :paramtype validation_key: str - :keyword subscriptions: Subscriptions delegation settings. - :paramtype subscriptions: - ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties - :keyword user_registration: User registration delegation settings. - :paramtype user_registration: - ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties - :keyword enabled: Redirect Anonymous users to the Sign-In page. - :paramtype enabled: bool - :keyword terms_of_service: Terms of service contract properties. - :paramtype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties - """ - super().__init__(**kwargs) - self.url = url - self.validation_key = validation_key - self.subscriptions = subscriptions - self.user_registration = user_registration - self.enabled = enabled - self.terms_of_service = terms_of_service - - -class PortalSettingValidationKeyContract(_serialization.Model): - """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - - :ivar validation_key: This is secret value of the validation key in portal settings. - :vartype validation_key: str - """ - - _attribute_map = { - "validation_key": {"key": "validationKey", "type": "str"}, - } - - def __init__(self, *, validation_key: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword validation_key: This is secret value of the validation key in portal settings. - :paramtype validation_key: str - """ - super().__init__(**kwargs) - self.validation_key = validation_key - - -class PortalSigninSettings(ProxyResource): - """Sign-In settings for the Developer Portal. - - 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 enabled: Redirect Anonymous users to the Sign-In page. - :vartype enabled: 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"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Redirect Anonymous users to the Sign-In page. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.enabled = enabled - - -class PortalSignupSettings(ProxyResource): - """Sign-Up settings for a developer portal. - - 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 enabled: Allow users to sign up on a developer portal. - :vartype enabled: bool - :ivar terms_of_service: Terms of service contract properties. - :vartype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties - """ - - _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"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "terms_of_service": {"key": "properties.termsOfService", "type": "TermsOfServiceProperties"}, - } - - def __init__( - self, - *, - enabled: Optional[bool] = None, - terms_of_service: Optional["_models.TermsOfServiceProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword enabled: Allow users to sign up on a developer portal. - :paramtype enabled: bool - :keyword terms_of_service: Terms of service contract properties. - :paramtype terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties - """ - super().__init__(**kwargs) - self.enabled = enabled - self.terms_of_service = terms_of_service - - -class PrivateEndpoint(_serialization.Model): - """The Private Endpoint resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM identifier for Private Endpoint. - :vartype id: str - """ - - _validation = { - "id": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(Resource): - """The Private Endpoint Connection resource. - - 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 private_endpoint: The resource of private end point. - :vartype private_endpoint: ~azure.mgmt.apimanagement.models.PrivateEndpoint - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between service consumer and provider. - :vartype private_link_service_connection_state: - ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", and "Failed". - :vartype provisioning_state: str or - ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - private_endpoint: Optional["_models.PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private end point. - :paramtype private_endpoint: ~azure.mgmt.apimanagement.models.PrivateEndpoint - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :paramtype private_link_service_connection_state: - ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state = None - - -class PrivateEndpointConnectionListResult(_serialization.Model): - """List of private endpoint connection associated with the specified storage account. - - :ivar value: Array of private endpoint connections. - :vartype value: list[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private endpoint connections. - :paramtype value: list[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateEndpointConnectionRequest(_serialization.Model): - """A request to approve or reject a private endpoint connection. - - :ivar id: Private Endpoint Connection Resource Id. - :vartype id: str - :ivar properties: The connection state of the private endpoint connection. - :vartype properties: - ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "properties": {"key": "properties", "type": "PrivateEndpointConnectionRequestProperties"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - properties: Optional["_models.PrivateEndpointConnectionRequestProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Private Endpoint Connection Resource Id. - :paramtype id: str - :keyword properties: The connection state of the private endpoint connection. - :paramtype properties: - ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequestProperties - """ - super().__init__(**kwargs) - self.id = id - self.properties = properties - - -class PrivateEndpointConnectionRequestProperties(_serialization.Model): # pylint: disable=name-too-long - """The connection state of the private endpoint connection. - - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between service consumer and provider. - :vartype private_link_service_connection_state: - ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState - """ - - _attribute_map = { - "private_link_service_connection_state": { - "key": "privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - } - - def __init__( - self, - *, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :paramtype private_link_service_connection_state: - ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.private_link_service_connection_state = private_link_service_connection_state - - -class PrivateLinkResource(Resource): - """A private link resource. - - 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: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :ivar required_zone_names: The private link resource Private link DNS zone name. - :vartype required_zone_names: list[str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "group_id": {"readonly": True}, - "required_members": {"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"}, - "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, - "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, - } - - def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword required_zone_names: The private link resource Private link DNS zone name. - :paramtype required_zone_names: list[str] - """ - super().__init__(**kwargs) - self.group_id = None - self.required_members = None - self.required_zone_names = required_zone_names - - -class PrivateLinkResourceListResult(_serialization.Model): - """A list of private link resources. - - :ivar value: Array of private link resources. - :vartype value: list[~azure.mgmt.apimanagement.models.PrivateLinkResource] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[PrivateLinkResource]"}, - } - - def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: - """ - :keyword value: Array of private link resources. - :paramtype value: list[~azure.mgmt.apimanagement.models.PrivateLinkResource] - """ - super().__init__(**kwargs) - self.value = value - - -class PrivateLinkServiceConnectionState(_serialization.Model): - """A collection of information about the state of the connection between service consumer and - provider. - - :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", and "Rejected". - :vartype status: str or ~azure.mgmt.apimanagement.models.PrivateEndpointServiceConnectionStatus - :ivar description: The reason for approval/rejection of the connection. - :vartype description: str - :ivar actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :vartype actions_required: str - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - "description": {"key": "description", "type": "str"}, - "actions_required": {"key": "actionsRequired", "type": "str"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", and "Rejected". - :paramtype status: str or - ~azure.mgmt.apimanagement.models.PrivateEndpointServiceConnectionStatus - :keyword description: The reason for approval/rejection of the connection. - :paramtype description: str - :keyword actions_required: A message indicating if changes on the service provider require any - updates on the consumer. - :paramtype actions_required: str - """ - super().__init__(**kwargs) - self.status = status - self.description = description - 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. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ProductContract] - :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": "[ProductContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ProductContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.ProductContract] - :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 ProductContract(ProxyResource): - """Product 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 description: Product description. May include HTML formatting tags. - :vartype description: str - :ivar terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :vartype terms: str - :ivar subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :vartype subscription_required: bool - :ivar approval_required: whether subscription approval is required. If false, new subscriptions - will be approved automatically enabling developers to call the product’s APIs immediately after - subscribing. If true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if subscriptionRequired property - is present and has a value of false. - :vartype approval_required: bool - :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :vartype subscriptions_limit: int - :ivar state: whether product is published or not. Published products are discoverable by users - of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Known values are: "notPublished" and "published". - :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState - :ivar display_name: Product name. - :vartype display_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "description": {"max_length": 1000}, - "display_name": {"max_length": 300, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "terms": {"key": "properties.terms", "type": "str"}, - "subscription_required": {"key": "properties.subscriptionRequired", "type": "bool"}, - "approval_required": {"key": "properties.approvalRequired", "type": "bool"}, - "subscriptions_limit": {"key": "properties.subscriptionsLimit", "type": "int"}, - "state": {"key": "properties.state", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - terms: Optional[str] = None, - subscription_required: Optional[bool] = None, - approval_required: Optional[bool] = None, - subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "_models.ProductState"]] = None, - display_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Product description. May include HTML formatting tags. - :paramtype description: str - :keyword terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :paramtype terms: str - :keyword subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :paramtype subscription_required: bool - :keyword approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :paramtype approval_required: bool - :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this - product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be - present only if subscriptionRequired property is present and has a value of false. - :paramtype subscriptions_limit: int - :keyword state: whether product is published or not. Published products are discoverable by - users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Known values are: "notPublished" and "published". - :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState - :keyword display_name: Product name. - :paramtype display_name: str - """ - super().__init__(**kwargs) - self.description = description - self.terms = terms - self.subscription_required = subscription_required - self.approval_required = approval_required - self.subscriptions_limit = subscriptions_limit - self.state = state - self.display_name = display_name - - -class ProductEntityBaseParameters(_serialization.Model): - """Product Entity Base Parameters. - - :ivar description: Product description. May include HTML formatting tags. - :vartype description: str - :ivar terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :vartype terms: str - :ivar subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :vartype subscription_required: bool - :ivar approval_required: whether subscription approval is required. If false, new subscriptions - will be approved automatically enabling developers to call the product’s APIs immediately after - subscribing. If true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if subscriptionRequired property - is present and has a value of false. - :vartype approval_required: bool - :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :vartype subscriptions_limit: int - :ivar state: whether product is published or not. Published products are discoverable by users - of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Known values are: "notPublished" and "published". - :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState - """ - - _validation = { - "description": {"max_length": 1000}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "terms": {"key": "terms", "type": "str"}, - "subscription_required": {"key": "subscriptionRequired", "type": "bool"}, - "approval_required": {"key": "approvalRequired", "type": "bool"}, - "subscriptions_limit": {"key": "subscriptionsLimit", "type": "int"}, - "state": {"key": "state", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - terms: Optional[str] = None, - subscription_required: Optional[bool] = None, - approval_required: Optional[bool] = None, - subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "_models.ProductState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Product description. May include HTML formatting tags. - :paramtype description: str - :keyword terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :paramtype terms: str - :keyword subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :paramtype subscription_required: bool - :keyword approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :paramtype approval_required: bool - :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this - product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be - present only if subscriptionRequired property is present and has a value of false. - :paramtype subscriptions_limit: int - :keyword state: whether product is published or not. Published products are discoverable by - users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Known values are: "notPublished" and "published". - :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState - """ - super().__init__(**kwargs) - self.description = description - self.terms = terms - self.subscription_required = subscription_required - self.approval_required = approval_required - self.subscriptions_limit = subscriptions_limit - self.state = state - - -class ProductContractProperties(ProductEntityBaseParameters): - """Product profile. - - All required parameters must be populated in order to send to server. - - :ivar description: Product description. May include HTML formatting tags. - :vartype description: str - :ivar terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :vartype terms: str - :ivar subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :vartype subscription_required: bool - :ivar approval_required: whether subscription approval is required. If false, new subscriptions - will be approved automatically enabling developers to call the product’s APIs immediately after - subscribing. If true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if subscriptionRequired property - is present and has a value of false. - :vartype approval_required: bool - :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :vartype subscriptions_limit: int - :ivar state: whether product is published or not. Published products are discoverable by users - of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Known values are: "notPublished" and "published". - :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState - :ivar display_name: Product name. Required. - :vartype display_name: str - """ - - _validation = { - "description": {"max_length": 1000}, - "display_name": {"required": True, "max_length": 300, "min_length": 1}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "terms": {"key": "terms", "type": "str"}, - "subscription_required": {"key": "subscriptionRequired", "type": "bool"}, - "approval_required": {"key": "approvalRequired", "type": "bool"}, - "subscriptions_limit": {"key": "subscriptionsLimit", "type": "int"}, - "state": {"key": "state", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - def __init__( - self, - *, - display_name: str, - description: Optional[str] = None, - terms: Optional[str] = None, - subscription_required: Optional[bool] = None, - approval_required: Optional[bool] = None, - subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "_models.ProductState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Product description. May include HTML formatting tags. - :paramtype description: str - :keyword terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :paramtype terms: str - :keyword subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :paramtype subscription_required: bool - :keyword approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :paramtype approval_required: bool - :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this - product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be - present only if subscriptionRequired property is present and has a value of false. - :paramtype subscriptions_limit: int - :keyword state: whether product is published or not. Published products are discoverable by - users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Known values are: "notPublished" and "published". - :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState - :keyword display_name: Product name. Required. - :paramtype display_name: str - """ - super().__init__( - description=description, - terms=terms, - subscription_required=subscription_required, - approval_required=approval_required, - subscriptions_limit=subscriptions_limit, - state=state, - **kwargs - ) - 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. - - All required parameters must be populated in order to send to server. - - :ivar description: Product description. May include HTML formatting tags. - :vartype description: str - :ivar terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :vartype terms: str - :ivar subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :vartype subscription_required: bool - :ivar approval_required: whether subscription approval is required. If false, new subscriptions - will be approved automatically enabling developers to call the product’s APIs immediately after - subscribing. If true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if subscriptionRequired property - is present and has a value of false. - :vartype approval_required: bool - :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :vartype subscriptions_limit: int - :ivar state: whether product is published or not. Published products are discoverable by users - of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Known values are: "notPublished" and "published". - :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState - :ivar id: Identifier of the product in the form of /products/{productId}. - :vartype id: str - :ivar name: Product name. Required. - :vartype name: str - """ - - _validation = { - "description": {"max_length": 1000}, - "name": {"required": True, "max_length": 300, "min_length": 1}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "terms": {"key": "terms", "type": "str"}, - "subscription_required": {"key": "subscriptionRequired", "type": "bool"}, - "approval_required": {"key": "approvalRequired", "type": "bool"}, - "subscriptions_limit": {"key": "subscriptionsLimit", "type": "int"}, - "state": {"key": "state", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - description: Optional[str] = None, - terms: Optional[str] = None, - subscription_required: Optional[bool] = None, - approval_required: Optional[bool] = None, - subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "_models.ProductState"]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword description: Product description. May include HTML formatting tags. - :paramtype description: str - :keyword terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :paramtype terms: str - :keyword subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :paramtype subscription_required: bool - :keyword approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :paramtype approval_required: bool - :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this - product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be - present only if subscriptionRequired property is present and has a value of false. - :paramtype subscriptions_limit: int - :keyword state: whether product is published or not. Published products are discoverable by - users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Known values are: "notPublished" and "published". - :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState - :keyword id: Identifier of the product in the form of /products/{productId}. - :paramtype id: str - :keyword name: Product name. Required. - :paramtype name: str - """ - super().__init__( - description=description, - terms=terms, - subscription_required=subscription_required, - approval_required=approval_required, - subscriptions_limit=subscriptions_limit, - state=state, - **kwargs - ) - self.id = id - self.name = name - - -class ProductUpdateParameters(_serialization.Model): - """Product Update parameters. - - :ivar description: Product description. May include HTML formatting tags. - :vartype description: str - :ivar terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :vartype terms: str - :ivar subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :vartype subscription_required: bool - :ivar approval_required: whether subscription approval is required. If false, new subscriptions - will be approved automatically enabling developers to call the product’s APIs immediately after - subscribing. If true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if subscriptionRequired property - is present and has a value of false. - :vartype approval_required: bool - :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :vartype subscriptions_limit: int - :ivar state: whether product is published or not. Published products are discoverable by users - of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Known values are: "notPublished" and "published". - :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState - :ivar display_name: Product name. - :vartype display_name: str - """ - - _validation = { - "description": {"max_length": 1000}, - "display_name": {"max_length": 300, "min_length": 1}, - } - - _attribute_map = { - "description": {"key": "properties.description", "type": "str"}, - "terms": {"key": "properties.terms", "type": "str"}, - "subscription_required": {"key": "properties.subscriptionRequired", "type": "bool"}, - "approval_required": {"key": "properties.approvalRequired", "type": "bool"}, - "subscriptions_limit": {"key": "properties.subscriptionsLimit", "type": "int"}, - "state": {"key": "properties.state", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - terms: Optional[str] = None, - subscription_required: Optional[bool] = None, - approval_required: Optional[bool] = None, - subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "_models.ProductState"]] = None, - display_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Product description. May include HTML formatting tags. - :paramtype description: str - :keyword terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :paramtype terms: str - :keyword subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :paramtype subscription_required: bool - :keyword approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :paramtype approval_required: bool - :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this - product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be - present only if subscriptionRequired property is present and has a value of false. - :paramtype subscriptions_limit: int - :keyword state: whether product is published or not. Published products are discoverable by - users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Known values are: "notPublished" and "published". - :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState - :keyword display_name: Product name. - :paramtype display_name: str - """ - super().__init__(**kwargs) - self.description = description - self.terms = terms - self.subscription_required = subscription_required - self.approval_required = approval_required - self.subscriptions_limit = subscriptions_limit - self.state = state - self.display_name = display_name - - -class ProductUpdateProperties(ProductEntityBaseParameters): - """Parameters supplied to the Update Product operation. - - :ivar description: Product description. May include HTML formatting tags. - :vartype description: str - :ivar terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :vartype terms: str - :ivar subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :vartype subscription_required: bool - :ivar approval_required: whether subscription approval is required. If false, new subscriptions - will be approved automatically enabling developers to call the product’s APIs immediately after - subscribing. If true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if subscriptionRequired property - is present and has a value of false. - :vartype approval_required: bool - :ivar subscriptions_limit: Whether the number of subscriptions a user can have to this product - at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present - only if subscriptionRequired property is present and has a value of false. - :vartype subscriptions_limit: int - :ivar state: whether product is published or not. Published products are discoverable by users - of developer portal. Non published products are visible only to administrators. Default state - of Product is notPublished. Known values are: "notPublished" and "published". - :vartype state: str or ~azure.mgmt.apimanagement.models.ProductState - :ivar display_name: Product name. - :vartype display_name: str - """ - - _validation = { - "description": {"max_length": 1000}, - "display_name": {"max_length": 300, "min_length": 1}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "terms": {"key": "terms", "type": "str"}, - "subscription_required": {"key": "subscriptionRequired", "type": "bool"}, - "approval_required": {"key": "approvalRequired", "type": "bool"}, - "subscriptions_limit": {"key": "subscriptionsLimit", "type": "int"}, - "state": {"key": "state", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - terms: Optional[str] = None, - subscription_required: Optional[bool] = None, - approval_required: Optional[bool] = None, - subscriptions_limit: Optional[int] = None, - state: Optional[Union[str, "_models.ProductState"]] = None, - display_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Product description. May include HTML formatting tags. - :paramtype description: str - :keyword terms: Product terms of use. Developers trying to subscribe to the product will be - presented and required to accept these terms before they can complete the subscription process. - :paramtype terms: str - :keyword subscription_required: Whether a product subscription is required for accessing APIs - included in this product. If true, the product is referred to as "protected" and a valid - subscription key is required for a request to an API included in the product to succeed. If - false, the product is referred to as "open" and requests to an API included in the product can - be made without a subscription key. If property is omitted when creating a new product it's - value is assumed to be true. - :paramtype subscription_required: bool - :keyword approval_required: whether subscription approval is required. If false, new - subscriptions will be approved automatically enabling developers to call the product’s APIs - immediately after subscribing. If true, administrators must manually approve the subscription - before the developer can any of the product’s APIs. Can be present only if subscriptionRequired - property is present and has a value of false. - :paramtype approval_required: bool - :keyword subscriptions_limit: Whether the number of subscriptions a user can have to this - product at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be - present only if subscriptionRequired property is present and has a value of false. - :paramtype subscriptions_limit: int - :keyword state: whether product is published or not. Published products are discoverable by - users of developer portal. Non published products are visible only to administrators. Default - state of Product is notPublished. Known values are: "notPublished" and "published". - :paramtype state: str or ~azure.mgmt.apimanagement.models.ProductState - :keyword display_name: Product name. - :paramtype display_name: str - """ - super().__init__( - description=description, - terms=terms, - subscription_required=subscription_required, - approval_required=approval_required, - subscriptions_limit=subscriptions_limit, - state=state, - **kwargs - ) - self.display_name = display_name - - -class QuotaCounterCollection(_serialization.Model): - """Paged Quota Counter list representation. - - :ivar value: Quota counter values. - :vartype value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] - :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": "[QuotaCounterContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.QuotaCounterContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Quota counter values. - :paramtype value: list[~azure.mgmt.apimanagement.models.QuotaCounterContract] - :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 QuotaCounterContract(_serialization.Model): - """Quota counter details. - - All required parameters must be populated in order to send to server. - - :ivar counter_key: The Key value of the Counter. Must not be empty. Required. - :vartype counter_key: str - :ivar period_key: Identifier of the Period for which the counter was collected. Must not be - empty. Required. - :vartype period_key: str - :ivar period_start_time: The date of the start of Counter Period. The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. - :vartype period_start_time: ~datetime.datetime - :ivar period_end_time: The date of the end of Counter Period. The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. - :vartype period_end_time: ~datetime.datetime - :ivar value: Quota Value Properties. - :vartype value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties - """ - - _validation = { - "counter_key": {"required": True, "min_length": 1}, - "period_key": {"required": True, "min_length": 1}, - "period_start_time": {"required": True}, - "period_end_time": {"required": True}, - } - - _attribute_map = { - "counter_key": {"key": "counterKey", "type": "str"}, - "period_key": {"key": "periodKey", "type": "str"}, - "period_start_time": {"key": "periodStartTime", "type": "iso-8601"}, - "period_end_time": {"key": "periodEndTime", "type": "iso-8601"}, - "value": {"key": "value", "type": "QuotaCounterValueContractProperties"}, - } - - def __init__( - self, - *, - counter_key: str, - period_key: str, - period_start_time: datetime.datetime, - period_end_time: datetime.datetime, - value: Optional["_models.QuotaCounterValueContractProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword counter_key: The Key value of the Counter. Must not be empty. Required. - :paramtype counter_key: str - :keyword period_key: Identifier of the Period for which the counter was collected. Must not be - empty. Required. - :paramtype period_key: str - :keyword period_start_time: The date of the start of Counter Period. The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. - :paramtype period_start_time: ~datetime.datetime - :keyword period_end_time: The date of the end of Counter Period. The date conforms to the - following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. Required. - :paramtype period_end_time: ~datetime.datetime - :keyword value: Quota Value Properties. - :paramtype value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties - """ - super().__init__(**kwargs) - self.counter_key = counter_key - self.period_key = period_key - self.period_start_time = period_start_time - self.period_end_time = period_end_time - self.value = value - - -class QuotaCounterValueContract(_serialization.Model): - """Quota counter value details. - - :ivar calls_count: Number of times Counter was called. - :vartype calls_count: int - :ivar kb_transferred: Data Transferred in KiloBytes. - :vartype kb_transferred: float - """ - - _attribute_map = { - "calls_count": {"key": "value.callsCount", "type": "int"}, - "kb_transferred": {"key": "value.kbTransferred", "type": "float"}, - } - - def __init__( - self, *, calls_count: Optional[int] = None, kb_transferred: Optional[float] = None, **kwargs: Any - ) -> None: - """ - :keyword calls_count: Number of times Counter was called. - :paramtype calls_count: int - :keyword kb_transferred: Data Transferred in KiloBytes. - :paramtype kb_transferred: float - """ - super().__init__(**kwargs) - self.calls_count = calls_count - self.kb_transferred = kb_transferred - - -class QuotaCounterValueContractProperties(_serialization.Model): - """Quota counter value details. - - :ivar calls_count: Number of times Counter was called. - :vartype calls_count: int - :ivar kb_transferred: Data Transferred in KiloBytes. - :vartype kb_transferred: float - """ - - _attribute_map = { - "calls_count": {"key": "callsCount", "type": "int"}, - "kb_transferred": {"key": "kbTransferred", "type": "float"}, - } - - def __init__( - self, *, calls_count: Optional[int] = None, kb_transferred: Optional[float] = None, **kwargs: Any - ) -> None: - """ - :keyword calls_count: Number of times Counter was called. - :paramtype calls_count: int - :keyword kb_transferred: Data Transferred in KiloBytes. - :paramtype kb_transferred: float - """ - super().__init__(**kwargs) - self.calls_count = calls_count - self.kb_transferred = kb_transferred - - -class QuotaCounterValueUpdateContract(_serialization.Model): - """Quota counter value details. - - :ivar calls_count: Number of times Counter was called. - :vartype calls_count: int - :ivar kb_transferred: Data Transferred in KiloBytes. - :vartype kb_transferred: float - """ - - _attribute_map = { - "calls_count": {"key": "properties.callsCount", "type": "int"}, - "kb_transferred": {"key": "properties.kbTransferred", "type": "float"}, - } - - def __init__( - self, *, calls_count: Optional[int] = None, kb_transferred: Optional[float] = None, **kwargs: Any - ) -> None: - """ - :keyword calls_count: Number of times Counter was called. - :paramtype calls_count: int - :keyword kb_transferred: Data Transferred in KiloBytes. - :paramtype kb_transferred: float - """ - super().__init__(**kwargs) - self.calls_count = calls_count - self.kb_transferred = kb_transferred - - -class RecipientEmailCollection(_serialization.Model): - """Paged Recipient User list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] - :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": "[RecipientEmailContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RecipientEmailContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.RecipientEmailContract] - :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 RecipientEmailContract(ProxyResource): - """Recipient Email 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 email: User Email subscribed to notification. - :vartype email: 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"}, - "email": {"key": "properties.email", "type": "str"}, - } - - def __init__(self, *, email: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword email: User Email subscribed to notification. - :paramtype email: str - """ - super().__init__(**kwargs) - self.email = email - - -class RecipientsContractProperties(_serialization.Model): - """Notification Parameter contract. - - :ivar emails: List of Emails subscribed for the notification. - :vartype emails: list[str] - :ivar users: List of Users subscribed for the notification. - :vartype users: list[str] - """ - - _attribute_map = { - "emails": {"key": "emails", "type": "[str]"}, - "users": {"key": "users", "type": "[str]"}, - } - - def __init__(self, *, emails: Optional[List[str]] = None, users: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword emails: List of Emails subscribed for the notification. - :paramtype emails: list[str] - :keyword users: List of Users subscribed for the notification. - :paramtype users: list[str] - """ - super().__init__(**kwargs) - self.emails = emails - self.users = users - - -class RecipientUserCollection(_serialization.Model): - """Paged Recipient User list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] - :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": "[RecipientUserContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RecipientUserContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.RecipientUserContract] - :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 RecipientUserContract(ProxyResource): - """Recipient User 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 user_id: API Management UserId subscribed to notification. - :vartype user_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"}, - "user_id": {"key": "properties.userId", "type": "str"}, - } - - def __init__(self, *, user_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword user_id: API Management UserId subscribed to notification. - :paramtype user_id: str - """ - super().__init__(**kwargs) - self.user_id = user_id - - -class RegionContract(_serialization.Model): - """Region profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Region name. - :vartype name: str - :ivar is_master_region: whether Region is the master region. - :vartype is_master_region: bool - :ivar is_deleted: whether Region is deleted. - :vartype is_deleted: bool - """ - - _validation = { - "name": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_master_region": {"key": "isMasterRegion", "type": "bool"}, - "is_deleted": {"key": "isDeleted", "type": "bool"}, - } - - def __init__( - self, *, is_master_region: Optional[bool] = None, is_deleted: Optional[bool] = None, **kwargs: Any - ) -> None: - """ - :keyword is_master_region: whether Region is the master region. - :paramtype is_master_region: bool - :keyword is_deleted: whether Region is deleted. - :paramtype is_deleted: bool - """ - super().__init__(**kwargs) - self.name = None - self.is_master_region = is_master_region - self.is_deleted = is_deleted - - -class RegionListResult(_serialization.Model): - """Lists Regions operation response details. - - :ivar value: Lists of Regions. - :vartype value: list[~azure.mgmt.apimanagement.models.RegionContract] - :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": "[RegionContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RegionContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Lists of Regions. - :paramtype value: list[~azure.mgmt.apimanagement.models.RegionContract] - :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 RegistrationDelegationSettingsProperties(_serialization.Model): - """User registration delegation settings properties. - - :ivar enabled: Enable or disable delegation for user registration. - :vartype enabled: bool - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Enable or disable delegation for user registration. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.enabled = enabled - - -class RemotePrivateEndpointConnectionWrapper(_serialization.Model): - """Remote Private Endpoint Connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Private Endpoint connection resource id. - :vartype id: str - :ivar name: Private Endpoint Connection Name. - :vartype name: str - :ivar type: Private Endpoint Connection Resource Type. - :vartype type: str - :ivar private_endpoint: The resource of private end point. - :vartype private_endpoint: ~azure.mgmt.apimanagement.models.ArmIdWrapper - :ivar private_link_service_connection_state: A collection of information about the state of the - connection between service consumer and provider. - :vartype private_link_service_connection_state: - ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState - :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - :vartype provisioning_state: str - :ivar group_ids: All the Group ids. - :vartype group_ids: list[str] - """ - - _validation = { - "provisioning_state": {"readonly": True}, - "group_ids": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "private_endpoint": {"key": "properties.privateEndpoint", "type": "ArmIdWrapper"}, - "private_link_service_connection_state": { - "key": "properties.privateLinkServiceConnectionState", - "type": "PrivateLinkServiceConnectionState", - }, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "group_ids": {"key": "properties.groupIds", "type": "[str]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - type: Optional[str] = None, - private_endpoint: Optional["_models.ArmIdWrapper"] = None, - private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Private Endpoint connection resource id. - :paramtype id: str - :keyword name: Private Endpoint Connection Name. - :paramtype name: str - :keyword type: Private Endpoint Connection Resource Type. - :paramtype type: str - :keyword private_endpoint: The resource of private end point. - :paramtype private_endpoint: ~azure.mgmt.apimanagement.models.ArmIdWrapper - :keyword private_link_service_connection_state: A collection of information about the state of - the connection between service consumer and provider. - :paramtype private_link_service_connection_state: - ~azure.mgmt.apimanagement.models.PrivateLinkServiceConnectionState - """ - super().__init__(**kwargs) - self.id = id - self.name = name - self.type = type - self.private_endpoint = private_endpoint - self.private_link_service_connection_state = private_link_service_connection_state - self.provisioning_state = None - self.group_ids = None - - -class ReportCollection(_serialization.Model): - """Paged Report records list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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": "[ReportRecordContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ReportRecordContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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 ReportRecordContract(_serialization.Model): - """Report data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name depending on report endpoint specifies product, API, operation or developer - name. - :vartype name: str - :ivar timestamp: Start of aggregation period. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype timestamp: ~datetime.datetime - :ivar interval: Length of aggregation period. Interval must be multiple of 15 minutes and may - not be zero. The value should be in ISO 8601 format - (http://en.wikipedia.org/wiki/ISO_8601#Durations). - :vartype interval: str - :ivar country: Country to which this record data is related. - :vartype country: str - :ivar region: Country region to which this record data is related. - :vartype region: str - :ivar zip: Zip code to which this record data is related. - :vartype zip: str - :ivar user_id: User identifier path. /users/{userId}. - :vartype user_id: str - :ivar product_id: Product identifier path. /products/{productId}. - :vartype product_id: str - :ivar api_id: API identifier path. /apis/{apiId}. - :vartype api_id: str - :ivar operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. - :vartype operation_id: str - :ivar api_region: API region identifier. - :vartype api_region: str - :ivar subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. - :vartype subscription_id: str - :ivar call_count_success: Number of successful calls. This includes calls returning - HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect. - :vartype call_count_success: int - :ivar call_count_blocked: Number of calls blocked due to invalid credentials. This includes - calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and - HttpStatusCode.TooManyRequests. - :vartype call_count_blocked: int - :ivar call_count_failed: Number of calls failed due to gateway or backend errors. This includes - calls returning HttpStatusCode.BadRequest(400) and any Code between - HttpStatusCode.InternalServerError (500) and 600. - :vartype call_count_failed: int - :ivar call_count_other: Number of other calls. - :vartype call_count_other: int - :ivar call_count_total: Total number of calls. - :vartype call_count_total: int - :ivar bandwidth: Bandwidth consumed. - :vartype bandwidth: int - :ivar cache_hit_count: Number of times when content was served from cache policy. - :vartype cache_hit_count: int - :ivar cache_miss_count: Number of times content was fetched from backend. - :vartype cache_miss_count: int - :ivar api_time_avg: Average time it took to process request. - :vartype api_time_avg: float - :ivar api_time_min: Minimum time it took to process request. - :vartype api_time_min: float - :ivar api_time_max: Maximum time it took to process request. - :vartype api_time_max: float - :ivar service_time_avg: Average time it took to process request on backend. - :vartype service_time_avg: float - :ivar service_time_min: Minimum time it took to process request on backend. - :vartype service_time_min: float - :ivar service_time_max: Maximum time it took to process request on backend. - :vartype service_time_max: float - """ - - _validation = { - "user_id": {"readonly": True}, - "product_id": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "interval": {"key": "interval", "type": "str"}, - "country": {"key": "country", "type": "str"}, - "region": {"key": "region", "type": "str"}, - "zip": {"key": "zip", "type": "str"}, - "user_id": {"key": "userId", "type": "str"}, - "product_id": {"key": "productId", "type": "str"}, - "api_id": {"key": "apiId", "type": "str"}, - "operation_id": {"key": "operationId", "type": "str"}, - "api_region": {"key": "apiRegion", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "call_count_success": {"key": "callCountSuccess", "type": "int"}, - "call_count_blocked": {"key": "callCountBlocked", "type": "int"}, - "call_count_failed": {"key": "callCountFailed", "type": "int"}, - "call_count_other": {"key": "callCountOther", "type": "int"}, - "call_count_total": {"key": "callCountTotal", "type": "int"}, - "bandwidth": {"key": "bandwidth", "type": "int"}, - "cache_hit_count": {"key": "cacheHitCount", "type": "int"}, - "cache_miss_count": {"key": "cacheMissCount", "type": "int"}, - "api_time_avg": {"key": "apiTimeAvg", "type": "float"}, - "api_time_min": {"key": "apiTimeMin", "type": "float"}, - "api_time_max": {"key": "apiTimeMax", "type": "float"}, - "service_time_avg": {"key": "serviceTimeAvg", "type": "float"}, - "service_time_min": {"key": "serviceTimeMin", "type": "float"}, - "service_time_max": {"key": "serviceTimeMax", "type": "float"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - name: Optional[str] = None, - timestamp: Optional[datetime.datetime] = None, - interval: Optional[str] = None, - country: Optional[str] = None, - region: Optional[str] = None, - zip: Optional[str] = None, - api_id: Optional[str] = None, - operation_id: Optional[str] = None, - api_region: Optional[str] = None, - subscription_id: Optional[str] = None, - call_count_success: Optional[int] = None, - call_count_blocked: Optional[int] = None, - call_count_failed: Optional[int] = None, - call_count_other: Optional[int] = None, - call_count_total: Optional[int] = None, - bandwidth: Optional[int] = None, - cache_hit_count: Optional[int] = None, - cache_miss_count: Optional[int] = None, - api_time_avg: Optional[float] = None, - api_time_min: Optional[float] = None, - api_time_max: Optional[float] = None, - service_time_avg: Optional[float] = None, - service_time_min: Optional[float] = None, - service_time_max: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: Name depending on report endpoint specifies product, API, operation or developer - name. - :paramtype name: str - :keyword timestamp: Start of aggregation period. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype timestamp: ~datetime.datetime - :keyword interval: Length of aggregation period. Interval must be multiple of 15 minutes and - may not be zero. The value should be in ISO 8601 format - (http://en.wikipedia.org/wiki/ISO_8601#Durations). - :paramtype interval: str - :keyword country: Country to which this record data is related. - :paramtype country: str - :keyword region: Country region to which this record data is related. - :paramtype region: str - :keyword zip: Zip code to which this record data is related. - :paramtype zip: str - :keyword api_id: API identifier path. /apis/{apiId}. - :paramtype api_id: str - :keyword operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. - :paramtype operation_id: str - :keyword api_region: API region identifier. - :paramtype api_region: str - :keyword subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. - :paramtype subscription_id: str - :keyword call_count_success: Number of successful calls. This includes calls returning - HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect. - :paramtype call_count_success: int - :keyword call_count_blocked: Number of calls blocked due to invalid credentials. This includes - calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and - HttpStatusCode.TooManyRequests. - :paramtype call_count_blocked: int - :keyword call_count_failed: Number of calls failed due to gateway or backend errors. This - includes calls returning HttpStatusCode.BadRequest(400) and any Code between - HttpStatusCode.InternalServerError (500) and 600. - :paramtype call_count_failed: int - :keyword call_count_other: Number of other calls. - :paramtype call_count_other: int - :keyword call_count_total: Total number of calls. - :paramtype call_count_total: int - :keyword bandwidth: Bandwidth consumed. - :paramtype bandwidth: int - :keyword cache_hit_count: Number of times when content was served from cache policy. - :paramtype cache_hit_count: int - :keyword cache_miss_count: Number of times content was fetched from backend. - :paramtype cache_miss_count: int - :keyword api_time_avg: Average time it took to process request. - :paramtype api_time_avg: float - :keyword api_time_min: Minimum time it took to process request. - :paramtype api_time_min: float - :keyword api_time_max: Maximum time it took to process request. - :paramtype api_time_max: float - :keyword service_time_avg: Average time it took to process request on backend. - :paramtype service_time_avg: float - :keyword service_time_min: Minimum time it took to process request on backend. - :paramtype service_time_min: float - :keyword service_time_max: Maximum time it took to process request on backend. - :paramtype service_time_max: float - """ - super().__init__(**kwargs) - self.name = name - self.timestamp = timestamp - self.interval = interval - self.country = country - self.region = region - self.zip = zip - self.user_id = None - self.product_id = None - self.api_id = api_id - self.operation_id = operation_id - self.api_region = api_region - self.subscription_id = subscription_id - self.call_count_success = call_count_success - self.call_count_blocked = call_count_blocked - self.call_count_failed = call_count_failed - self.call_count_other = call_count_other - self.call_count_total = call_count_total - self.bandwidth = bandwidth - self.cache_hit_count = cache_hit_count - self.cache_miss_count = cache_miss_count - self.api_time_avg = api_time_avg - self.api_time_min = api_time_min - self.api_time_max = api_time_max - self.service_time_avg = service_time_avg - self.service_time_min = service_time_min - self.service_time_max = service_time_max - - -class RepresentationContract(_serialization.Model): - """Operation request/response representation details. - - All required parameters must be populated in order to send to server. - - :ivar content_type: Specifies a registered or custom content type for this representation, e.g. - application/xml. Required. - :vartype content_type: str - :ivar schema_id: Schema identifier. Applicable only if 'contentType' value is neither - 'application/x-www-form-urlencoded' nor 'multipart/form-data'. - :vartype schema_id: str - :ivar type_name: Type name defined by the schema. Applicable only if 'contentType' value is - neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. - :vartype type_name: str - :ivar form_parameters: Collection of form parameters. Required if 'contentType' value is either - 'application/x-www-form-urlencoded' or 'multipart/form-data'.. - :vartype form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :ivar examples: Exampled defined for the representation. - :vartype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] - """ - - _validation = { - "content_type": {"required": True}, - } - - _attribute_map = { - "content_type": {"key": "contentType", "type": "str"}, - "schema_id": {"key": "schemaId", "type": "str"}, - "type_name": {"key": "typeName", "type": "str"}, - "form_parameters": {"key": "formParameters", "type": "[ParameterContract]"}, - "examples": {"key": "examples", "type": "{ParameterExampleContract}"}, - } - - def __init__( - self, - *, - content_type: str, - schema_id: Optional[str] = None, - type_name: Optional[str] = None, - form_parameters: Optional[List["_models.ParameterContract"]] = None, - examples: Optional[Dict[str, "_models.ParameterExampleContract"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword content_type: Specifies a registered or custom content type for this representation, - e.g. application/xml. Required. - :paramtype content_type: str - :keyword schema_id: Schema identifier. Applicable only if 'contentType' value is neither - 'application/x-www-form-urlencoded' nor 'multipart/form-data'. - :paramtype schema_id: str - :keyword type_name: Type name defined by the schema. Applicable only if 'contentType' value is - neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. - :paramtype type_name: str - :keyword form_parameters: Collection of form parameters. Required if 'contentType' value is - either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. - :paramtype form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :keyword examples: Exampled defined for the representation. - :paramtype examples: dict[str, ~azure.mgmt.apimanagement.models.ParameterExampleContract] - """ - super().__init__(**kwargs) - self.content_type = content_type - self.schema_id = schema_id - self.type_name = type_name - self.form_parameters = form_parameters - self.examples = examples - - -class RequestContract(_serialization.Model): - """Operation request details. - - :ivar description: Operation request description. - :vartype description: str - :ivar query_parameters: Collection of operation request query parameters. - :vartype query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :ivar headers: Collection of operation request headers. - :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] - :ivar representations: Collection of operation request representations. - :vartype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] - """ - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "query_parameters": {"key": "queryParameters", "type": "[ParameterContract]"}, - "headers": {"key": "headers", "type": "[ParameterContract]"}, - "representations": {"key": "representations", "type": "[RepresentationContract]"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - query_parameters: Optional[List["_models.ParameterContract"]] = None, - headers: Optional[List["_models.ParameterContract"]] = None, - representations: Optional[List["_models.RepresentationContract"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Operation request description. - :paramtype description: str - :keyword query_parameters: Collection of operation request query parameters. - :paramtype query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] - :keyword headers: Collection of operation request headers. - :paramtype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] - :keyword representations: Collection of operation request representations. - :paramtype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] - """ - super().__init__(**kwargs) - self.description = description - self.query_parameters = query_parameters - self.headers = headers - self.representations = representations - - -class RequestReportCollection(_serialization.Model): - """Paged Report records list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] - :ivar count: Total record count number across all pages. - :vartype count: int - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RequestReportRecordContract]"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.RequestReportRecordContract"]] = None, - count: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = value - self.count = count - - -class RequestReportRecordContract(_serialization.Model): - """Request Report data. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar api_id: API identifier path. /apis/{apiId}. - :vartype api_id: str - :ivar operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. - :vartype operation_id: str - :ivar product_id: Product identifier path. /products/{productId}. - :vartype product_id: str - :ivar user_id: User identifier path. /users/{userId}. - :vartype user_id: str - :ivar method: The HTTP method associated with this request.. - :vartype method: str - :ivar url: The full URL associated with this request. - :vartype url: str - :ivar ip_address: The client IP address associated with this request. - :vartype ip_address: str - :ivar backend_response_code: The HTTP status code received by the gateway as a result of - forwarding this request to the backend. - :vartype backend_response_code: str - :ivar response_code: The HTTP status code returned by the gateway. - :vartype response_code: int - :ivar response_size: The size of the response returned by the gateway. - :vartype response_size: int - :ivar timestamp: The date and time when this request was received by the gateway in ISO 8601 - format. - :vartype timestamp: ~datetime.datetime - :ivar cache: Specifies if response cache was involved in generating the response. If the value - is none, the cache was not used. If the value is hit, cached response was returned. If the - value is miss, the cache was used but lookup resulted in a miss and request was fulfilled by - the backend. - :vartype cache: str - :ivar api_time: The total time it took to process this request. - :vartype api_time: float - :ivar service_time: he time it took to forward this request to the backend and get the response - back. - :vartype service_time: float - :ivar api_region: Azure region where the gateway that processed this request is located. - :vartype api_region: str - :ivar subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. - :vartype subscription_id: str - :ivar request_id: Request Identifier. - :vartype request_id: str - :ivar request_size: The size of this request.. - :vartype request_size: int - """ - - _validation = { - "product_id": {"readonly": True}, - "user_id": {"readonly": True}, - } - - _attribute_map = { - "api_id": {"key": "apiId", "type": "str"}, - "operation_id": {"key": "operationId", "type": "str"}, - "product_id": {"key": "productId", "type": "str"}, - "user_id": {"key": "userId", "type": "str"}, - "method": {"key": "method", "type": "str"}, - "url": {"key": "url", "type": "str"}, - "ip_address": {"key": "ipAddress", "type": "str"}, - "backend_response_code": {"key": "backendResponseCode", "type": "str"}, - "response_code": {"key": "responseCode", "type": "int"}, - "response_size": {"key": "responseSize", "type": "int"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "cache": {"key": "cache", "type": "str"}, - "api_time": {"key": "apiTime", "type": "float"}, - "service_time": {"key": "serviceTime", "type": "float"}, - "api_region": {"key": "apiRegion", "type": "str"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "request_id": {"key": "requestId", "type": "str"}, - "request_size": {"key": "requestSize", "type": "int"}, - } - - def __init__( - self, - *, - api_id: Optional[str] = None, - operation_id: Optional[str] = None, - method: Optional[str] = None, - url: Optional[str] = None, - ip_address: Optional[str] = None, - backend_response_code: Optional[str] = None, - response_code: Optional[int] = None, - response_size: Optional[int] = None, - timestamp: Optional[datetime.datetime] = None, - cache: Optional[str] = None, - api_time: Optional[float] = None, - service_time: Optional[float] = None, - api_region: Optional[str] = None, - subscription_id: Optional[str] = None, - request_id: Optional[str] = None, - request_size: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :keyword api_id: API identifier path. /apis/{apiId}. - :paramtype api_id: str - :keyword operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. - :paramtype operation_id: str - :keyword method: The HTTP method associated with this request.. - :paramtype method: str - :keyword url: The full URL associated with this request. - :paramtype url: str - :keyword ip_address: The client IP address associated with this request. - :paramtype ip_address: str - :keyword backend_response_code: The HTTP status code received by the gateway as a result of - forwarding this request to the backend. - :paramtype backend_response_code: str - :keyword response_code: The HTTP status code returned by the gateway. - :paramtype response_code: int - :keyword response_size: The size of the response returned by the gateway. - :paramtype response_size: int - :keyword timestamp: The date and time when this request was received by the gateway in ISO 8601 - format. - :paramtype timestamp: ~datetime.datetime - :keyword cache: Specifies if response cache was involved in generating the response. If the - value is none, the cache was not used. If the value is hit, cached response was returned. If - the value is miss, the cache was used but lookup resulted in a miss and request was fulfilled - by the backend. - :paramtype cache: str - :keyword api_time: The total time it took to process this request. - :paramtype api_time: float - :keyword service_time: he time it took to forward this request to the backend and get the - response back. - :paramtype service_time: float - :keyword api_region: Azure region where the gateway that processed this request is located. - :paramtype api_region: str - :keyword subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. - :paramtype subscription_id: str - :keyword request_id: Request Identifier. - :paramtype request_id: str - :keyword request_size: The size of this request.. - :paramtype request_size: int - """ - super().__init__(**kwargs) - self.api_id = api_id - self.operation_id = operation_id - self.product_id = None - self.user_id = None - self.method = method - self.url = url - self.ip_address = ip_address - self.backend_response_code = backend_response_code - self.response_code = response_code - self.response_size = response_size - self.timestamp = timestamp - self.cache = cache - self.api_time = api_time - self.service_time = service_time - self.api_region = api_region - self.subscription_id = subscription_id - self.request_id = request_id - self.request_size = request_size - - -class ResolverCollection(_serialization.Model): - """Paged Resolver list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.ResolverContract] - :ivar count: Total record count number across all pages. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ResolverContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number across all pages. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class ResolverContract(ProxyResource): - """GraphQL API Resolver 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: Resolver Name. - :vartype display_name: str - :ivar path: Path is type/field being resolved. - :vartype path: str - :ivar description: Description of the resolver. May include HTML formatting tags. - :vartype description: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"max_length": 300, "min_length": 1}, - "path": {"max_length": 300, "min_length": 1}, - "description": {"max_length": 1000}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "path": {"key": "properties.path", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - path: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: Resolver Name. - :paramtype display_name: str - :keyword path: Path is type/field being resolved. - :paramtype path: str - :keyword description: Description of the resolver. May include HTML formatting tags. - :paramtype description: str - """ - super().__init__(**kwargs) - self.display_name = display_name - self.path = path - self.description = description - - -class ResolverResultContract(ProxyResource): - """Long Running Git Resolver Results. - - 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 id_properties_id: Resolver result identifier. - :vartype id_properties_id: str - :ivar status: Status of an async resolver. Known values are: "Started", "InProgress", - "Succeeded", and "Failed". - :vartype status: str or ~azure.mgmt.apimanagement.models.AsyncResolverStatus - :ivar started: Start time of an async resolver. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype started: ~datetime.datetime - :ivar updated: Last update time of an async resolver. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype updated: ~datetime.datetime - :ivar result_info: Optional result info. - :vartype result_info: str - :ivar error: Error Body Contract. - :vartype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody - :ivar action_log: This property if only provided as part of the TenantConfiguration_Validate - resolver. It contains the log the entities which will be updated/created/deleted as part of the - TenantConfiguration_Deploy resolver. - :vartype action_log: list[~azure.mgmt.apimanagement.models.ResolverResultLogItemContract] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "action_log": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "id_properties_id": {"key": "properties.id", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "started": {"key": "properties.started", "type": "iso-8601"}, - "updated": {"key": "properties.updated", "type": "iso-8601"}, - "result_info": {"key": "properties.resultInfo", "type": "str"}, - "error": {"key": "properties.error", "type": "ErrorResponseBody"}, - "action_log": {"key": "properties.actionLog", "type": "[ResolverResultLogItemContract]"}, - } - - def __init__( - self, - *, - id_properties_id: Optional[str] = None, - status: Optional[Union[str, "_models.AsyncResolverStatus"]] = None, - started: Optional[datetime.datetime] = None, - updated: Optional[datetime.datetime] = None, - result_info: Optional[str] = None, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs: Any - ) -> None: - """ - :keyword id_properties_id: Resolver result identifier. - :paramtype id_properties_id: str - :keyword status: Status of an async resolver. Known values are: "Started", "InProgress", - "Succeeded", and "Failed". - :paramtype status: str or ~azure.mgmt.apimanagement.models.AsyncResolverStatus - :keyword started: Start time of an async resolver. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype started: ~datetime.datetime - :keyword updated: Last update time of an async resolver. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype updated: ~datetime.datetime - :keyword result_info: Optional result info. - :paramtype result_info: str - :keyword error: Error Body Contract. - :paramtype error: ~azure.mgmt.apimanagement.models.ErrorResponseBody - """ - super().__init__(**kwargs) - self.id_properties_id = id_properties_id - self.status = status - self.started = started - self.updated = updated - self.result_info = result_info - self.error = error - self.action_log = None - - -class ResolverResultLogItemContract(_serialization.Model): - """Log of the entity being created, updated or deleted. - - :ivar object_type: The type of entity contract. - :vartype object_type: str - :ivar action: Action like create/update/delete. - :vartype action: str - :ivar object_key: Identifier of the entity being created/updated/deleted. - :vartype object_key: str - """ - - _attribute_map = { - "object_type": {"key": "objectType", "type": "str"}, - "action": {"key": "action", "type": "str"}, - "object_key": {"key": "objectKey", "type": "str"}, - } - - def __init__( - self, - *, - object_type: Optional[str] = None, - action: Optional[str] = None, - object_key: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword object_type: The type of entity contract. - :paramtype object_type: str - :keyword action: Action like create/update/delete. - :paramtype action: str - :keyword object_key: Identifier of the entity being created/updated/deleted. - :paramtype object_key: str - """ - super().__init__(**kwargs) - self.object_type = object_type - self.action = action - self.object_key = object_key - - -class ResolverUpdateContract(_serialization.Model): - """GraphQL API Resolver Update Contract details. - - :ivar display_name: Resolver Name. - :vartype display_name: str - :ivar path: Path is type/field being resolved. - :vartype path: str - :ivar description: Description of the resolver. May include HTML formatting tags. - :vartype description: str - """ - - _validation = { - "display_name": {"max_length": 300, "min_length": 1}, - "path": {"max_length": 300, "min_length": 1}, - "description": {"max_length": 1000}, - } - - _attribute_map = { - "display_name": {"key": "properties.displayName", "type": "str"}, - "path": {"key": "properties.path", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - path: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword display_name: Resolver Name. - :paramtype display_name: str - :keyword path: Path is type/field being resolved. - :paramtype path: str - :keyword description: Description of the resolver. May include HTML formatting tags. - :paramtype description: str - """ - super().__init__(**kwargs) - self.display_name = display_name - self.path = path - self.description = description - - -class ResourceCollection(_serialization.Model): - """A collection of resources. - - :ivar value: A collection of resources. - :vartype value: list[~azure.mgmt.apimanagement.models.ResourceCollectionValueItem] - :ivar count: Total record count number. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[ResourceCollectionValueItem]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.ResourceCollectionValueItem"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: A collection of resources. - :paramtype value: list[~azure.mgmt.apimanagement.models.ResourceCollectionValueItem] - :keyword count: Total record count number. - :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 ResourceCollectionValueItem(ProxyResource): - """ResourceCollectionValueItem. - - 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 - """ - - -class ResourceLocationDataContract(_serialization.Model): - """Resource location data properties. - - All required parameters must be populated in order to send to server. - - :ivar name: A canonical name for the geographic or physical location. Required. - :vartype name: str - :ivar city: The city or locality where the resource is located. - :vartype city: str - :ivar district: The district, state, or province where the resource is located. - :vartype district: str - :ivar country_or_region: The country or region where the resource is located. - :vartype country_or_region: str - """ - - _validation = { - "name": {"required": True, "max_length": 256}, - "city": {"max_length": 256}, - "district": {"max_length": 256}, - "country_or_region": {"max_length": 256}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "city": {"key": "city", "type": "str"}, - "district": {"key": "district", "type": "str"}, - "country_or_region": {"key": "countryOrRegion", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - city: Optional[str] = None, - district: Optional[str] = None, - country_or_region: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: A canonical name for the geographic or physical location. Required. - :paramtype name: str - :keyword city: The city or locality where the resource is located. - :paramtype city: str - :keyword district: The district, state, or province where the resource is located. - :paramtype district: str - :keyword country_or_region: The country or region where the resource is located. - :paramtype country_or_region: str - """ - super().__init__(**kwargs) - self.name = name - self.city = city - self.district = district - self.country_or_region = country_or_region - - -class ResourceSku(_serialization.Model): - """Describes an available API Management SKU. - - :ivar name: Name of the Sku. Known values are: "Developer", "Standard", "Premium", "Basic", - "Consumption", "Isolated", "BasicV2", and "StandardV2". - :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: "Developer", "Standard", "Premium", "Basic", - "Consumption", "Isolated", "BasicV2", and "StandardV2". - :paramtype name: str or ~azure.mgmt.apimanagement.models.SkuType - """ - super().__init__(**kwargs) - self.name = name - - -class ResourceSkuCapacity(_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.ResourceSkuCapacityScaleType - """ - - _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 ResourceSkuResult(_serialization.Model): - """Describes an available API Management service 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 SKU. - :vartype sku: ~azure.mgmt.apimanagement.models.ResourceSku - :ivar capacity: Specifies the number of API Management units. - :vartype capacity: ~azure.mgmt.apimanagement.models.ResourceSkuCapacity - """ - - _validation = { - "resource_type": {"readonly": True}, - "sku": {"readonly": True}, - "capacity": {"readonly": True}, - } - - _attribute_map = { - "resource_type": {"key": "resourceType", "type": "str"}, - "sku": {"key": "sku", "type": "ResourceSku"}, - "capacity": {"key": "capacity", "type": "ResourceSkuCapacity"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.resource_type = None - self.sku = None - self.capacity = None - - -class ResourceSkuResults(_serialization.Model): - """The API Management service SKUs operation response. - - All required parameters must be populated in order to send to server. - - :ivar value: The list of skus available for the service. Required. - :vartype value: list[~azure.mgmt.apimanagement.models.ResourceSkuResult] - :ivar next_link: The uri to fetch the next page of API Management service Skus. - :vartype next_link: str - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ResourceSkuResult]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: List["_models.ResourceSkuResult"], next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of skus available for the service. Required. - :paramtype value: list[~azure.mgmt.apimanagement.models.ResourceSkuResult] - :keyword next_link: The uri to fetch the next page of API Management service Skus. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ResponseContract(_serialization.Model): - """Operation response details. - - All required parameters must be populated in order to send to server. - - :ivar status_code: Operation response HTTP status code. Required. - :vartype status_code: int - :ivar description: Operation response description. - :vartype description: str - :ivar representations: Collection of operation response representations. - :vartype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] - :ivar headers: Collection of operation response headers. - :vartype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] - """ - - _validation = { - "status_code": {"required": True}, - } - - _attribute_map = { - "status_code": {"key": "statusCode", "type": "int"}, - "description": {"key": "description", "type": "str"}, - "representations": {"key": "representations", "type": "[RepresentationContract]"}, - "headers": {"key": "headers", "type": "[ParameterContract]"}, - } - - def __init__( - self, - *, - status_code: int, - description: Optional[str] = None, - representations: Optional[List["_models.RepresentationContract"]] = None, - headers: Optional[List["_models.ParameterContract"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword status_code: Operation response HTTP status code. Required. - :paramtype status_code: int - :keyword description: Operation response description. - :paramtype description: str - :keyword representations: Collection of operation response representations. - :paramtype representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] - :keyword headers: Collection of operation response headers. - :paramtype headers: list[~azure.mgmt.apimanagement.models.ParameterContract] - """ - super().__init__(**kwargs) - self.status_code = status_code - self.description = description - self.representations = representations - self.headers = headers - - -class SamplingSettings(_serialization.Model): - """Sampling settings for Diagnostic. - - :ivar sampling_type: Sampling type. "fixed" - :vartype sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType - :ivar percentage: Rate of sampling for fixed-rate sampling. - :vartype percentage: float - """ - - _validation = { - "percentage": {"maximum": 100, "minimum": 0}, - } - - _attribute_map = { - "sampling_type": {"key": "samplingType", "type": "str"}, - "percentage": {"key": "percentage", "type": "float"}, - } - - def __init__( - self, - *, - sampling_type: Optional[Union[str, "_models.SamplingType"]] = None, - percentage: Optional[float] = None, - **kwargs: Any - ) -> None: - """ - :keyword sampling_type: Sampling type. "fixed" - :paramtype sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType - :keyword percentage: Rate of sampling for fixed-rate sampling. - :paramtype percentage: float - """ - super().__init__(**kwargs) - self.sampling_type = sampling_type - self.percentage = percentage - - -class SaveConfigurationParameter(_serialization.Model): - """Save Tenant Configuration Contract details. - - :ivar branch: The name of the Git branch in which to commit the current configuration snapshot. - :vartype branch: str - :ivar force: The value if true, the current configuration database is committed to the Git - repository, even if the Git repository has newer changes that would be overwritten. - :vartype force: bool - """ - - _attribute_map = { - "branch": {"key": "properties.branch", "type": "str"}, - "force": {"key": "properties.force", "type": "bool"}, - } - - def __init__(self, *, branch: Optional[str] = None, force: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword branch: The name of the Git branch in which to commit the current configuration - snapshot. - :paramtype branch: str - :keyword force: The value if true, the current configuration database is committed to the Git - repository, even if the Git repository has newer changes that would be overwritten. - :paramtype force: bool - """ - super().__init__(**kwargs) - self.branch = branch - self.force = force - - -class SchemaCollection(_serialization.Model): - """The response of the list schema operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: API Schema Contract value. - :vartype value: list[~azure.mgmt.apimanagement.models.SchemaContract] - :ivar count: Total record count number. - :vartype count: int - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SchemaContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, *, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword count: Total record count number. - :paramtype count: int - """ - super().__init__(**kwargs) - self.value = None - self.count = count - self.next_link = None - - -class SchemaContract(ProxyResource): - """API Schema 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 content_type: Must be a valid a media type used in a Content-Type header as defined in - the RFC 2616. Media type of the schema document (e.g. application/json, application/xml).
- - ``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``
- ``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 - :ivar definitions: Types definitions. Used for Swagger/OpenAPI v1 schemas only, null otherwise. - :vartype definitions: JSON - :ivar components: Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null - otherwise. - :vartype components: JSON - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "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"}, - } - - def __init__( - self, - *, - content_type: Optional[str] = None, - value: Optional[str] = None, - definitions: Optional[JSON] = None, - components: Optional[JSON] = None, - **kwargs: Any - ) -> None: - """ - :keyword content_type: Must be a valid a media type used in a Content-Type header as defined in - the RFC 2616. Media type of the schema document (e.g. application/json, application/xml).
- - ``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``
- ``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. - :paramtype value: str - :keyword definitions: Types definitions. Used for Swagger/OpenAPI v1 schemas only, null - otherwise. - :paramtype definitions: JSON - :keyword components: Types definitions. Used for Swagger/OpenAPI v2/v3 schemas only, null - otherwise. - :paramtype components: JSON - """ - super().__init__(**kwargs) - self.content_type = content_type - self.provisioning_state = None - self.value = value - self.definitions = definitions - self.components = components - - -class SubscriptionCollection(_serialization.Model): - """Paged Subscriptions list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] - :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": "[SubscriptionContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.SubscriptionContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] - :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 SubscriptionContract(ProxyResource): - """Subscription 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 owner_id: The user resource identifier of the subscription owner. The value is a valid - relative URL in the format of /users/{userId} where {userId} is a user identifier. - :vartype owner_id: str - :ivar scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :vartype scope: str - :ivar display_name: The name of the subscription, or null if the subscription has no name. - :vartype display_name: str - :ivar state: Subscription state. Possible states are * active – the subscription is active, * - suspended – the subscription is blocked, and the subscriber cannot call any APIs of the - product, * submitted – the subscription request has been made by the developer, but has not yet - been approved or rejected, * rejected – the subscription request has been denied by an - administrator, * cancelled – the subscription has been cancelled by the developer or - administrator, * expired – the subscription reached its expiration date and was deactivated. - Known values are: "suspended", "active", "expired", "submitted", "rejected", and "cancelled". - :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :ivar created_date: Subscription creation date. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype created_date: ~datetime.datetime - :ivar start_date: Subscription activation date. The setting is for audit purposes only and the - subscription is not automatically activated. The subscription lifecycle can be managed by using - the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as - specified by the ISO 8601 standard. - :vartype start_date: ~datetime.datetime - :ivar expiration_date: Subscription expiration date. The setting is for audit purposes only and - the subscription is not automatically expired. The subscription lifecycle can be managed by - using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype expiration_date: ~datetime.datetime - :ivar end_date: Date when subscription was cancelled or expired. The setting is for audit - purposes only and the subscription is not automatically cancelled. The subscription lifecycle - can be managed by using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype end_date: ~datetime.datetime - :ivar notification_date: Upcoming subscription expiration notification date. The date conforms - to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype notification_date: ~datetime.datetime - :ivar primary_key: Subscription primary key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :vartype primary_key: str - :ivar secondary_key: Subscription secondary key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :vartype secondary_key: str - :ivar state_comment: Optional subscription comment added by an administrator when the state is - changed to the 'rejected'. - :vartype state_comment: str - :ivar allow_tracing: Determines whether tracing is enabled. - :vartype allow_tracing: bool - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"max_length": 100}, - "created_date": {"readonly": True}, - "primary_key": {"max_length": 256, "min_length": 1}, - "secondary_key": {"max_length": 256, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "owner_id": {"key": "properties.ownerId", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "created_date": {"key": "properties.createdDate", "type": "iso-8601"}, - "start_date": {"key": "properties.startDate", "type": "iso-8601"}, - "expiration_date": {"key": "properties.expirationDate", "type": "iso-8601"}, - "end_date": {"key": "properties.endDate", "type": "iso-8601"}, - "notification_date": {"key": "properties.notificationDate", "type": "iso-8601"}, - "primary_key": {"key": "properties.primaryKey", "type": "str"}, - "secondary_key": {"key": "properties.secondaryKey", "type": "str"}, - "state_comment": {"key": "properties.stateComment", "type": "str"}, - "allow_tracing": {"key": "properties.allowTracing", "type": "bool"}, - } - - def __init__( - self, - *, - owner_id: Optional[str] = None, - scope: Optional[str] = None, - display_name: Optional[str] = None, - state: Optional[Union[str, "_models.SubscriptionState"]] = None, - start_date: Optional[datetime.datetime] = None, - expiration_date: Optional[datetime.datetime] = None, - end_date: Optional[datetime.datetime] = None, - notification_date: Optional[datetime.datetime] = None, - primary_key: Optional[str] = None, - secondary_key: Optional[str] = None, - state_comment: Optional[str] = None, - allow_tracing: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword owner_id: The user resource identifier of the subscription owner. The value is a valid - relative URL in the format of /users/{userId} where {userId} is a user identifier. - :paramtype owner_id: str - :keyword scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :paramtype scope: str - :keyword display_name: The name of the subscription, or null if the subscription has no name. - :paramtype display_name: str - :keyword state: Subscription state. Possible states are * active – the subscription is active, - * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the - product, * submitted – the subscription request has been made by the developer, but has not yet - been approved or rejected, * rejected – the subscription request has been denied by an - administrator, * cancelled – the subscription has been cancelled by the developer or - administrator, * expired – the subscription reached its expiration date and was deactivated. - Known values are: "suspended", "active", "expired", "submitted", "rejected", and "cancelled". - :paramtype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :keyword start_date: Subscription activation date. The setting is for audit purposes only and - the subscription is not automatically activated. The subscription lifecycle can be managed by - using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype start_date: ~datetime.datetime - :keyword expiration_date: Subscription expiration date. The setting is for audit purposes only - and the subscription is not automatically expired. The subscription lifecycle can be managed by - using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype expiration_date: ~datetime.datetime - :keyword end_date: Date when subscription was cancelled or expired. The setting is for audit - purposes only and the subscription is not automatically cancelled. The subscription lifecycle - can be managed by using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype end_date: ~datetime.datetime - :keyword notification_date: Upcoming subscription expiration notification date. The date - conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 - standard. - :paramtype notification_date: ~datetime.datetime - :keyword primary_key: Subscription primary key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :paramtype primary_key: str - :keyword secondary_key: Subscription secondary key. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. - :paramtype secondary_key: str - :keyword state_comment: Optional subscription comment added by an administrator when the state - is changed to the 'rejected'. - :paramtype state_comment: str - :keyword allow_tracing: Determines whether tracing is enabled. - :paramtype allow_tracing: bool - """ - super().__init__(**kwargs) - self.owner_id = owner_id - self.scope = scope - self.display_name = display_name - self.state = state - self.created_date = None - self.start_date = start_date - self.expiration_date = expiration_date - self.end_date = end_date - self.notification_date = notification_date - self.primary_key = primary_key - self.secondary_key = secondary_key - self.state_comment = state_comment - self.allow_tracing = allow_tracing - - -class SubscriptionCreateParameters(_serialization.Model): - """Subscription create details. - - :ivar owner_id: User (user id path) for whom subscription is being created in form - /users/{userId}. - :vartype owner_id: str - :ivar scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :vartype scope: str - :ivar display_name: Subscription name. - :vartype display_name: str - :ivar primary_key: Primary subscription key. If not specified during request key will be - generated automatically. - :vartype primary_key: str - :ivar secondary_key: Secondary subscription key. If not specified during request key will be - generated automatically. - :vartype secondary_key: str - :ivar state: Initial subscription state. If no value is specified, subscription is created with - Submitted state. Possible states are * active – the subscription is active, * suspended – the - subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – - the subscription request has been made by the developer, but has not yet been approved or - rejected, * rejected – the subscription request has been denied by an administrator, * - cancelled – the subscription has been cancelled by the developer or administrator, * expired – - the subscription reached its expiration date and was deactivated. Known values are: - "suspended", "active", "expired", "submitted", "rejected", and "cancelled". - :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :ivar allow_tracing: Determines whether tracing can be enabled. - :vartype allow_tracing: bool - """ - - _validation = { - "display_name": {"max_length": 100, "min_length": 1}, - "primary_key": {"max_length": 256, "min_length": 1}, - "secondary_key": {"max_length": 256, "min_length": 1}, - } - - _attribute_map = { - "owner_id": {"key": "properties.ownerId", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "primary_key": {"key": "properties.primaryKey", "type": "str"}, - "secondary_key": {"key": "properties.secondaryKey", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "allow_tracing": {"key": "properties.allowTracing", "type": "bool"}, - } - - def __init__( - self, - *, - owner_id: Optional[str] = None, - scope: Optional[str] = None, - display_name: Optional[str] = None, - primary_key: Optional[str] = None, - secondary_key: Optional[str] = None, - state: Optional[Union[str, "_models.SubscriptionState"]] = None, - allow_tracing: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword owner_id: User (user id path) for whom subscription is being created in form - /users/{userId}. - :paramtype owner_id: str - :keyword scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :paramtype scope: str - :keyword display_name: Subscription name. - :paramtype display_name: str - :keyword primary_key: Primary subscription key. If not specified during request key will be - generated automatically. - :paramtype primary_key: str - :keyword secondary_key: Secondary subscription key. If not specified during request key will be - generated automatically. - :paramtype secondary_key: str - :keyword state: Initial subscription state. If no value is specified, subscription is created - with Submitted state. Possible states are * active – the subscription is active, * suspended – - the subscription is blocked, and the subscriber cannot call any APIs of the product, * - submitted – the subscription request has been made by the developer, but has not yet been - approved or rejected, * rejected – the subscription request has been denied by an - administrator, * cancelled – the subscription has been cancelled by the developer or - administrator, * expired – the subscription reached its expiration date and was deactivated. - Known values are: "suspended", "active", "expired", "submitted", "rejected", and "cancelled". - :paramtype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :keyword allow_tracing: Determines whether tracing can be enabled. - :paramtype allow_tracing: bool - """ - super().__init__(**kwargs) - self.owner_id = owner_id - self.scope = scope - self.display_name = display_name - self.primary_key = primary_key - self.secondary_key = secondary_key - self.state = state - self.allow_tracing = allow_tracing - - -class SubscriptionKeyParameterNamesContract(_serialization.Model): - """Subscription key parameter names details. - - :ivar header: Subscription key header name. - :vartype header: str - :ivar query: Subscription key query string parameter name. - :vartype query: str - """ - - _attribute_map = { - "header": {"key": "header", "type": "str"}, - "query": {"key": "query", "type": "str"}, - } - - def __init__(self, *, header: Optional[str] = None, query: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword header: Subscription key header name. - :paramtype header: str - :keyword query: Subscription key query string parameter name. - :paramtype query: str - """ - super().__init__(**kwargs) - self.header = header - self.query = query - - -class SubscriptionKeysContract(_serialization.Model): - """Subscription keys. - - :ivar primary_key: Subscription primary key. - :vartype primary_key: str - :ivar secondary_key: Subscription secondary key. - :vartype secondary_key: str - """ - - _validation = { - "primary_key": {"max_length": 256, "min_length": 1}, - "secondary_key": {"max_length": 256, "min_length": 1}, - } - - _attribute_map = { - "primary_key": {"key": "primaryKey", "type": "str"}, - "secondary_key": {"key": "secondaryKey", "type": "str"}, - } - - def __init__( - self, *, primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword primary_key: Subscription primary key. - :paramtype primary_key: str - :keyword secondary_key: Subscription secondary key. - :paramtype secondary_key: str - """ - super().__init__(**kwargs) - self.primary_key = primary_key - self.secondary_key = secondary_key - - -class SubscriptionsDelegationSettingsProperties(_serialization.Model): # pylint: disable=name-too-long - """Subscriptions delegation settings properties. - - :ivar enabled: Enable or disable delegation for subscriptions. - :vartype enabled: bool - """ - - _attribute_map = { - "enabled": {"key": "enabled", "type": "bool"}, - } - - def __init__(self, *, enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword enabled: Enable or disable delegation for subscriptions. - :paramtype enabled: bool - """ - super().__init__(**kwargs) - self.enabled = enabled - - -class SubscriptionUpdateParameters(_serialization.Model): - """Subscription update details. - - :ivar owner_id: User identifier path: /users/{userId}. - :vartype owner_id: str - :ivar scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :vartype scope: str - :ivar expiration_date: Subscription expiration date. The setting is for audit purposes only and - the subscription is not automatically expired. The subscription lifecycle can be managed by - using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype expiration_date: ~datetime.datetime - :ivar display_name: Subscription name. - :vartype display_name: str - :ivar primary_key: Primary subscription key. - :vartype primary_key: str - :ivar secondary_key: Secondary subscription key. - :vartype secondary_key: str - :ivar state: Subscription state. Possible states are * active – the subscription is active, * - suspended – the subscription is blocked, and the subscriber cannot call any APIs of the - product, * submitted – the subscription request has been made by the developer, but has not yet - been approved or rejected, * rejected – the subscription request has been denied by an - administrator, * cancelled – the subscription has been cancelled by the developer or - administrator, * expired – the subscription reached its expiration date and was deactivated. - Known values are: "suspended", "active", "expired", "submitted", "rejected", and "cancelled". - :vartype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :ivar state_comment: Comments describing subscription state change by the administrator when - the state is changed to the 'rejected'. - :vartype state_comment: str - :ivar allow_tracing: Determines whether tracing can be enabled. - :vartype allow_tracing: bool - """ - - _validation = { - "primary_key": {"max_length": 256, "min_length": 1}, - "secondary_key": {"max_length": 256, "min_length": 1}, - } - - _attribute_map = { - "owner_id": {"key": "properties.ownerId", "type": "str"}, - "scope": {"key": "properties.scope", "type": "str"}, - "expiration_date": {"key": "properties.expirationDate", "type": "iso-8601"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - "primary_key": {"key": "properties.primaryKey", "type": "str"}, - "secondary_key": {"key": "properties.secondaryKey", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "state_comment": {"key": "properties.stateComment", "type": "str"}, - "allow_tracing": {"key": "properties.allowTracing", "type": "bool"}, - } - - def __init__( - self, - *, - owner_id: Optional[str] = None, - scope: Optional[str] = None, - expiration_date: Optional[datetime.datetime] = None, - display_name: Optional[str] = None, - primary_key: Optional[str] = None, - secondary_key: Optional[str] = None, - state: Optional[Union[str, "_models.SubscriptionState"]] = None, - state_comment: Optional[str] = None, - allow_tracing: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword owner_id: User identifier path: /users/{userId}. - :paramtype owner_id: str - :keyword scope: Scope like /products/{productId} or /apis or /apis/{apiId}. - :paramtype scope: str - :keyword expiration_date: Subscription expiration date. The setting is for audit purposes only - and the subscription is not automatically expired. The subscription lifecycle can be managed by - using the ``state`` property. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype expiration_date: ~datetime.datetime - :keyword display_name: Subscription name. - :paramtype display_name: str - :keyword primary_key: Primary subscription key. - :paramtype primary_key: str - :keyword secondary_key: Secondary subscription key. - :paramtype secondary_key: str - :keyword state: Subscription state. Possible states are * active – the subscription is active, - * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the - product, * submitted – the subscription request has been made by the developer, but has not yet - been approved or rejected, * rejected – the subscription request has been denied by an - administrator, * cancelled – the subscription has been cancelled by the developer or - administrator, * expired – the subscription reached its expiration date and was deactivated. - Known values are: "suspended", "active", "expired", "submitted", "rejected", and "cancelled". - :paramtype state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :keyword state_comment: Comments describing subscription state change by the administrator when - the state is changed to the 'rejected'. - :paramtype state_comment: str - :keyword allow_tracing: Determines whether tracing can be enabled. - :paramtype allow_tracing: bool - """ - super().__init__(**kwargs) - self.owner_id = owner_id - self.scope = scope - self.expiration_date = expiration_date - self.display_name = display_name - self.primary_key = primary_key - self.secondary_key = secondary_key - self.state = state - self.state_comment = state_comment - self.allow_tracing = allow_tracing - - -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.apimanagement.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "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: - """ - :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 api_id: Full resource Id of an API. - :paramtype api_id: str - """ - super().__init__(**kwargs) - self.api_id = api_id - - -class TagCollection(_serialization.Model): - """Paged Tag list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.TagContract] - :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": "[TagContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.TagContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.TagContract] - :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 TagContract(ProxyResource): - """Tag 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 display_name: Tag name. - :vartype display_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "display_name": {"max_length": 160, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - } - - def __init__(self, *, display_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword display_name: Tag name. - :paramtype display_name: str - """ - super().__init__(**kwargs) - self.display_name = display_name - - -class TagCreateUpdateParameters(_serialization.Model): - """Parameters supplied to Create/Update Tag operations. - - :ivar display_name: Tag name. - :vartype display_name: str - """ - - _validation = { - "display_name": {"max_length": 160, "min_length": 1}, - } - - _attribute_map = { - "display_name": {"key": "properties.displayName", "type": "str"}, - } - - def __init__(self, *, display_name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword display_name: Tag name. - :paramtype display_name: str - """ - super().__init__(**kwargs) - self.display_name = display_name - - -class TagDescriptionBaseProperties(_serialization.Model): - """Parameters supplied to the Create TagDescription operation. - - :ivar description: Description of the Tag. - :vartype description: str - :ivar external_docs_url: Absolute URL of external resources describing the tag. - :vartype external_docs_url: str - :ivar external_docs_description: Description of the external resources describing the tag. - :vartype external_docs_description: str - """ - - _validation = { - "external_docs_url": {"max_length": 2000}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "external_docs_url": {"key": "externalDocsUrl", "type": "str"}, - "external_docs_description": {"key": "externalDocsDescription", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - external_docs_url: Optional[str] = None, - external_docs_description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the Tag. - :paramtype description: str - :keyword external_docs_url: Absolute URL of external resources describing the tag. - :paramtype external_docs_url: str - :keyword external_docs_description: Description of the external resources describing the tag. - :paramtype external_docs_description: str - """ - super().__init__(**kwargs) - self.description = description - self.external_docs_url = external_docs_url - self.external_docs_description = external_docs_description - - -class TagDescriptionCollection(_serialization.Model): - """Paged TagDescription list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] - :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": "[TagDescriptionContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.TagDescriptionContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] - :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 TagDescriptionContract(ProxyResource): - """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 description: Description of the Tag. - :vartype description: str - :ivar external_docs_url: Absolute URL of external resources describing the tag. - :vartype external_docs_url: str - :ivar external_docs_description: Description of the external resources describing the tag. - :vartype external_docs_description: str - :ivar tag_id: Identifier of the tag in the form of /tags/{tagId}. - :vartype tag_id: str - :ivar display_name: Tag name. - :vartype display_name: str - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "external_docs_url": {"max_length": 2000}, - "display_name": {"max_length": 160, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "description": {"key": "properties.description", "type": "str"}, - "external_docs_url": {"key": "properties.externalDocsUrl", "type": "str"}, - "external_docs_description": {"key": "properties.externalDocsDescription", "type": "str"}, - "tag_id": {"key": "properties.tagId", "type": "str"}, - "display_name": {"key": "properties.displayName", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - external_docs_url: Optional[str] = None, - external_docs_description: Optional[str] = None, - tag_id: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the Tag. - :paramtype description: str - :keyword external_docs_url: Absolute URL of external resources describing the tag. - :paramtype external_docs_url: str - :keyword external_docs_description: Description of the external resources describing the tag. - :paramtype external_docs_description: str - :keyword tag_id: Identifier of the tag in the form of /tags/{tagId}. - :paramtype tag_id: str - :keyword display_name: Tag name. - :paramtype display_name: str - """ - super().__init__(**kwargs) - self.description = description - self.external_docs_url = external_docs_url - self.external_docs_description = external_docs_description - self.tag_id = tag_id - self.display_name = display_name - - -class TagDescriptionContractProperties(TagDescriptionBaseProperties): - """TagDescription contract Properties. - - :ivar description: Description of the Tag. - :vartype description: str - :ivar external_docs_url: Absolute URL of external resources describing the tag. - :vartype external_docs_url: str - :ivar external_docs_description: Description of the external resources describing the tag. - :vartype external_docs_description: str - :ivar tag_id: Identifier of the tag in the form of /tags/{tagId}. - :vartype tag_id: str - :ivar display_name: Tag name. - :vartype display_name: str - """ - - _validation = { - "external_docs_url": {"max_length": 2000}, - "display_name": {"max_length": 160, "min_length": 1}, - } - - _attribute_map = { - "description": {"key": "description", "type": "str"}, - "external_docs_url": {"key": "externalDocsUrl", "type": "str"}, - "external_docs_description": {"key": "externalDocsDescription", "type": "str"}, - "tag_id": {"key": "tagId", "type": "str"}, - "display_name": {"key": "displayName", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - external_docs_url: Optional[str] = None, - external_docs_description: Optional[str] = None, - tag_id: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the Tag. - :paramtype description: str - :keyword external_docs_url: Absolute URL of external resources describing the tag. - :paramtype external_docs_url: str - :keyword external_docs_description: Description of the external resources describing the tag. - :paramtype external_docs_description: str - :keyword tag_id: Identifier of the tag in the form of /tags/{tagId}. - :paramtype tag_id: str - :keyword display_name: Tag name. - :paramtype display_name: str - """ - super().__init__( - description=description, - external_docs_url=external_docs_url, - external_docs_description=external_docs_description, - **kwargs - ) - self.tag_id = tag_id - self.display_name = display_name - - -class TagDescriptionCreateParameters(_serialization.Model): - """Parameters supplied to the Create TagDescription operation. - - :ivar description: Description of the Tag. - :vartype description: str - :ivar external_docs_url: Absolute URL of external resources describing the tag. - :vartype external_docs_url: str - :ivar external_docs_description: Description of the external resources describing the tag. - :vartype external_docs_description: str - """ - - _validation = { - "external_docs_url": {"max_length": 2000}, - } - - _attribute_map = { - "description": {"key": "properties.description", "type": "str"}, - "external_docs_url": {"key": "properties.externalDocsUrl", "type": "str"}, - "external_docs_description": {"key": "properties.externalDocsDescription", "type": "str"}, - } - - def __init__( - self, - *, - description: Optional[str] = None, - external_docs_url: Optional[str] = None, - external_docs_description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword description: Description of the Tag. - :paramtype description: str - :keyword external_docs_url: Absolute URL of external resources describing the tag. - :paramtype external_docs_url: str - :keyword external_docs_description: Description of the external resources describing the tag. - :paramtype external_docs_description: str - """ - super().__init__(**kwargs) - self.description = description - self.external_docs_url = external_docs_url - 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. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.TagResourceContract] - :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": "[TagResourceContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.TagResourceContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.TagResourceContract] - :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 TagResourceContract(_serialization.Model): - """TagResource contract properties. - - All required parameters must be populated in order to send to server. - - :ivar tag: Tag associated with the resource. Required. - :vartype tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties - :ivar api: API associated with the tag. - :vartype api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties - :ivar operation: Operation associated with the tag. - :vartype operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties - :ivar product: Product associated with the tag. - :vartype product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties - """ - - _validation = { - "tag": {"required": True}, - } - - _attribute_map = { - "tag": {"key": "tag", "type": "TagResourceContractProperties"}, - "api": {"key": "api", "type": "ApiTagResourceContractProperties"}, - "operation": {"key": "operation", "type": "OperationTagResourceContractProperties"}, - "product": {"key": "product", "type": "ProductTagResourceContractProperties"}, - } - - def __init__( - self, - *, - tag: "_models.TagResourceContractProperties", - api: Optional["_models.ApiTagResourceContractProperties"] = None, - operation: Optional["_models.OperationTagResourceContractProperties"] = None, - product: Optional["_models.ProductTagResourceContractProperties"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tag: Tag associated with the resource. Required. - :paramtype tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties - :keyword api: API associated with the tag. - :paramtype api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties - :keyword operation: Operation associated with the tag. - :paramtype operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties - :keyword product: Product associated with the tag. - :paramtype product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties - """ - super().__init__(**kwargs) - self.tag = tag - self.api = api - self.operation = operation - self.product = product - - -class TagResourceContractProperties(_serialization.Model): - """Contract defining the Tag property in the Tag Resource Contract. - - :ivar id: Tag identifier. - :vartype id: str - :ivar name: Tag Name. - :vartype name: str - """ - - _validation = { - "name": {"max_length": 160, "min_length": 1}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: Tag identifier. - :paramtype id: str - :keyword name: Tag Name. - :paramtype name: str - """ - super().__init__(**kwargs) - self.id = id - self.name = name - - -class TenantConfigurationSyncStateContract(ProxyResource): - """Result of Tenant Configuration Sync State. - - 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 branch: The name of Git branch. - :vartype branch: str - :ivar commit_id: The latest commit Id. - :vartype commit_id: str - :ivar is_export: value indicating if last sync was save (true) or deploy (false) operation. - :vartype is_export: bool - :ivar is_synced: value indicating if last synchronization was later than the configuration - change. - :vartype is_synced: bool - :ivar is_git_enabled: value indicating whether Git configuration access is enabled. - :vartype is_git_enabled: bool - :ivar sync_date: The date of the latest synchronization. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype sync_date: ~datetime.datetime - :ivar configuration_change_date: The date of the latest configuration change. The date conforms - to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype configuration_change_date: ~datetime.datetime - :ivar last_operation_id: Most recent tenant configuration operation identifier. - :vartype last_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"}, - "branch": {"key": "properties.branch", "type": "str"}, - "commit_id": {"key": "properties.commitId", "type": "str"}, - "is_export": {"key": "properties.isExport", "type": "bool"}, - "is_synced": {"key": "properties.isSynced", "type": "bool"}, - "is_git_enabled": {"key": "properties.isGitEnabled", "type": "bool"}, - "sync_date": {"key": "properties.syncDate", "type": "iso-8601"}, - "configuration_change_date": {"key": "properties.configurationChangeDate", "type": "iso-8601"}, - "last_operation_id": {"key": "properties.lastOperationId", "type": "str"}, - } - - def __init__( - self, - *, - branch: Optional[str] = None, - commit_id: Optional[str] = None, - is_export: Optional[bool] = None, - is_synced: Optional[bool] = None, - is_git_enabled: Optional[bool] = None, - sync_date: Optional[datetime.datetime] = None, - configuration_change_date: Optional[datetime.datetime] = None, - last_operation_id: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword branch: The name of Git branch. - :paramtype branch: str - :keyword commit_id: The latest commit Id. - :paramtype commit_id: str - :keyword is_export: value indicating if last sync was save (true) or deploy (false) operation. - :paramtype is_export: bool - :keyword is_synced: value indicating if last synchronization was later than the configuration - change. - :paramtype is_synced: bool - :keyword is_git_enabled: value indicating whether Git configuration access is enabled. - :paramtype is_git_enabled: bool - :keyword sync_date: The date of the latest synchronization. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype sync_date: ~datetime.datetime - :keyword configuration_change_date: The date of the latest configuration change. The date - conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 - standard. - :paramtype configuration_change_date: ~datetime.datetime - :keyword last_operation_id: Most recent tenant configuration operation identifier. - :paramtype last_operation_id: str - """ - super().__init__(**kwargs) - self.branch = branch - self.commit_id = commit_id - self.is_export = is_export - self.is_synced = is_synced - self.is_git_enabled = is_git_enabled - self.sync_date = sync_date - self.configuration_change_date = configuration_change_date - self.last_operation_id = last_operation_id - - -class TenantSettingsCollection(_serialization.Model): - """Paged AccessInformation list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.TenantSettingsContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[TenantSettingsContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class TenantSettingsContract(ProxyResource): - """Tenant Settings. - - 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 settings: Tenant settings. - :vartype settings: 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"}, - "settings": {"key": "properties.settings", "type": "{str}"}, - } - - def __init__(self, *, settings: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword settings: Tenant settings. - :paramtype settings: dict[str, str] - """ - super().__init__(**kwargs) - self.settings = settings - - -class TermsOfServiceProperties(_serialization.Model): - """Terms of service contract properties. - - :ivar text: A terms of service text. - :vartype text: str - :ivar enabled: Display terms of service during a sign-up process. - :vartype enabled: bool - :ivar consent_required: Ask user for consent to the terms of service. - :vartype consent_required: bool - """ - - _attribute_map = { - "text": {"key": "text", "type": "str"}, - "enabled": {"key": "enabled", "type": "bool"}, - "consent_required": {"key": "consentRequired", "type": "bool"}, - } - - def __init__( - self, - *, - text: Optional[str] = None, - enabled: Optional[bool] = None, - consent_required: Optional[bool] = None, - **kwargs: Any - ) -> None: - """ - :keyword text: A terms of service text. - :paramtype text: str - :keyword enabled: Display terms of service during a sign-up process. - :paramtype enabled: bool - :keyword consent_required: Ask user for consent to the terms of service. - :paramtype consent_required: bool - """ - super().__init__(**kwargs) - self.text = text - self.enabled = enabled - self.consent_required = consent_required - - -class TokenBodyParameterContract(_serialization.Model): - """OAuth acquire token request body parameter (www-url-form-encoded). - - All required parameters must be populated in order to send to server. - - :ivar name: body parameter name. Required. - :vartype name: str - :ivar value: body parameter value. Required. - :vartype value: str - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: - """ - :keyword name: body parameter name. Required. - :paramtype name: str - :keyword value: body parameter value. Required. - :paramtype value: str - """ - super().__init__(**kwargs) - self.name = name - self.value = value - - -class UserCollection(_serialization.Model): - """Paged Users list representation. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.UserContract] - :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": "[UserContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.UserContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: Page values. - :paramtype value: list[~azure.mgmt.apimanagement.models.UserContract] - :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 UserContract(ProxyResource): - """User 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 state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :vartype state: str or ~azure.mgmt.apimanagement.models.UserState - :ivar note: Optional note about a user set by the administrator. - :vartype note: str - :ivar identities: Collection of user identities. - :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :ivar first_name: First name. - :vartype first_name: str - :ivar last_name: Last name. - :vartype last_name: str - :ivar email: Email address. - :vartype email: str - :ivar registration_date: Date of user registration. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype registration_date: ~datetime.datetime - :ivar groups: Collection of groups user is part of. - :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "groups": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "state": {"key": "properties.state", "type": "str"}, - "note": {"key": "properties.note", "type": "str"}, - "identities": {"key": "properties.identities", "type": "[UserIdentityContract]"}, - "first_name": {"key": "properties.firstName", "type": "str"}, - "last_name": {"key": "properties.lastName", "type": "str"}, - "email": {"key": "properties.email", "type": "str"}, - "registration_date": {"key": "properties.registrationDate", "type": "iso-8601"}, - "groups": {"key": "properties.groups", "type": "[GroupContractProperties]"}, - } - - def __init__( - self, - *, - state: Union[str, "_models.UserState"] = "active", - note: Optional[str] = None, - identities: Optional[List["_models.UserIdentityContract"]] = None, - first_name: Optional[str] = None, - last_name: Optional[str] = None, - email: Optional[str] = None, - registration_date: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState - :keyword note: Optional note about a user set by the administrator. - :paramtype note: str - :keyword identities: Collection of user identities. - :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :keyword first_name: First name. - :paramtype first_name: str - :keyword last_name: Last name. - :paramtype last_name: str - :keyword email: Email address. - :paramtype email: str - :keyword registration_date: Date of user registration. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype registration_date: ~datetime.datetime - """ - super().__init__(**kwargs) - self.state = state - self.note = note - self.identities = identities - self.first_name = first_name - self.last_name = last_name - self.email = email - self.registration_date = registration_date - self.groups = None - - -class UserEntityBaseParameters(_serialization.Model): - """User Entity Base Parameters set. - - :ivar state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :vartype state: str or ~azure.mgmt.apimanagement.models.UserState - :ivar note: Optional note about a user set by the administrator. - :vartype note: str - :ivar identities: Collection of user identities. - :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - """ - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "note": {"key": "note", "type": "str"}, - "identities": {"key": "identities", "type": "[UserIdentityContract]"}, - } - - def __init__( - self, - *, - state: Union[str, "_models.UserState"] = "active", - note: Optional[str] = None, - identities: Optional[List["_models.UserIdentityContract"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState - :keyword note: Optional note about a user set by the administrator. - :paramtype note: str - :keyword identities: Collection of user identities. - :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - """ - super().__init__(**kwargs) - self.state = state - self.note = note - self.identities = identities - - -class UserContractProperties(UserEntityBaseParameters): - """User profile. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :vartype state: str or ~azure.mgmt.apimanagement.models.UserState - :ivar note: Optional note about a user set by the administrator. - :vartype note: str - :ivar identities: Collection of user identities. - :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :ivar first_name: First name. - :vartype first_name: str - :ivar last_name: Last name. - :vartype last_name: str - :ivar email: Email address. - :vartype email: str - :ivar registration_date: Date of user registration. The date conforms to the following format: - ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :vartype registration_date: ~datetime.datetime - :ivar groups: Collection of groups user is part of. - :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] - """ - - _validation = { - "groups": {"readonly": True}, - } - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "note": {"key": "note", "type": "str"}, - "identities": {"key": "identities", "type": "[UserIdentityContract]"}, - "first_name": {"key": "firstName", "type": "str"}, - "last_name": {"key": "lastName", "type": "str"}, - "email": {"key": "email", "type": "str"}, - "registration_date": {"key": "registrationDate", "type": "iso-8601"}, - "groups": {"key": "groups", "type": "[GroupContractProperties]"}, - } - - def __init__( - self, - *, - state: Union[str, "_models.UserState"] = "active", - note: Optional[str] = None, - identities: Optional[List["_models.UserIdentityContract"]] = None, - first_name: Optional[str] = None, - last_name: Optional[str] = None, - email: Optional[str] = None, - registration_date: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState - :keyword note: Optional note about a user set by the administrator. - :paramtype note: str - :keyword identities: Collection of user identities. - :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :keyword first_name: First name. - :paramtype first_name: str - :keyword last_name: Last name. - :paramtype last_name: str - :keyword email: Email address. - :paramtype email: str - :keyword registration_date: Date of user registration. The date conforms to the following - format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :paramtype registration_date: ~datetime.datetime - """ - super().__init__(state=state, note=note, identities=identities, **kwargs) - self.first_name = first_name - self.last_name = last_name - self.email = email - self.registration_date = registration_date - self.groups = None - - -class UserCreateParameterProperties(UserEntityBaseParameters): - """Parameters supplied to the Create User operation. - - All required parameters must be populated in order to send to server. - - :ivar state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :vartype state: str or ~azure.mgmt.apimanagement.models.UserState - :ivar note: Optional note about a user set by the administrator. - :vartype note: str - :ivar identities: Collection of user identities. - :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :ivar email: Email address. Must not be empty and must be unique within the service instance. - Required. - :vartype email: str - :ivar first_name: First name. Required. - :vartype first_name: str - :ivar last_name: Last name. Required. - :vartype last_name: str - :ivar password: User Password. If no value is provided, a default password is generated. - :vartype password: str - :ivar app_type: Determines the type of application which send the create user request. Default - is legacy portal. Known values are: "portal" and "developerPortal". - :vartype app_type: str or ~azure.mgmt.apimanagement.models.AppType - :ivar confirmation: Determines the type of confirmation e-mail that will be sent to the newly - created user. Known values are: "signup" and "invite". - :vartype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation - """ - - _validation = { - "email": {"required": True, "max_length": 254, "min_length": 1}, - "first_name": {"required": True, "max_length": 100, "min_length": 1}, - "last_name": {"required": True, "max_length": 100, "min_length": 1}, - } - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "note": {"key": "note", "type": "str"}, - "identities": {"key": "identities", "type": "[UserIdentityContract]"}, - "email": {"key": "email", "type": "str"}, - "first_name": {"key": "firstName", "type": "str"}, - "last_name": {"key": "lastName", "type": "str"}, - "password": {"key": "password", "type": "str"}, - "app_type": {"key": "appType", "type": "str"}, - "confirmation": {"key": "confirmation", "type": "str"}, - } - - def __init__( - self, - *, - email: str, - first_name: str, - last_name: str, - state: Union[str, "_models.UserState"] = "active", - note: Optional[str] = None, - identities: Optional[List["_models.UserIdentityContract"]] = None, - password: Optional[str] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, - confirmation: Optional[Union[str, "_models.Confirmation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState - :keyword note: Optional note about a user set by the administrator. - :paramtype note: str - :keyword identities: Collection of user identities. - :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :keyword email: Email address. Must not be empty and must be unique within the service - instance. Required. - :paramtype email: str - :keyword first_name: First name. Required. - :paramtype first_name: str - :keyword last_name: Last name. Required. - :paramtype last_name: str - :keyword password: User Password. If no value is provided, a default password is generated. - :paramtype password: str - :keyword app_type: Determines the type of application which send the create user request. - Default is legacy portal. Known values are: "portal" and "developerPortal". - :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType - :keyword confirmation: Determines the type of confirmation e-mail that will be sent to the - newly created user. Known values are: "signup" and "invite". - :paramtype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation - """ - super().__init__(state=state, note=note, identities=identities, **kwargs) - self.email = email - self.first_name = first_name - self.last_name = last_name - self.password = password - self.app_type = app_type - self.confirmation = confirmation - - -class UserCreateParameters(_serialization.Model): - """User create details. - - :ivar state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :vartype state: str or ~azure.mgmt.apimanagement.models.UserState - :ivar note: Optional note about a user set by the administrator. - :vartype note: str - :ivar identities: Collection of user identities. - :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :ivar email: Email address. Must not be empty and must be unique within the service instance. - :vartype email: str - :ivar first_name: First name. - :vartype first_name: str - :ivar last_name: Last name. - :vartype last_name: str - :ivar password: User Password. If no value is provided, a default password is generated. - :vartype password: str - :ivar app_type: Determines the type of application which send the create user request. Default - is legacy portal. Known values are: "portal" and "developerPortal". - :vartype app_type: str or ~azure.mgmt.apimanagement.models.AppType - :ivar confirmation: Determines the type of confirmation e-mail that will be sent to the newly - created user. Known values are: "signup" and "invite". - :vartype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation - """ - - _validation = { - "email": {"max_length": 254, "min_length": 1}, - "first_name": {"max_length": 100, "min_length": 1}, - "last_name": {"max_length": 100, "min_length": 1}, - } - - _attribute_map = { - "state": {"key": "properties.state", "type": "str"}, - "note": {"key": "properties.note", "type": "str"}, - "identities": {"key": "properties.identities", "type": "[UserIdentityContract]"}, - "email": {"key": "properties.email", "type": "str"}, - "first_name": {"key": "properties.firstName", "type": "str"}, - "last_name": {"key": "properties.lastName", "type": "str"}, - "password": {"key": "properties.password", "type": "str"}, - "app_type": {"key": "properties.appType", "type": "str"}, - "confirmation": {"key": "properties.confirmation", "type": "str"}, - } - - def __init__( - self, - *, - state: Union[str, "_models.UserState"] = "active", - note: Optional[str] = None, - identities: Optional[List["_models.UserIdentityContract"]] = None, - email: Optional[str] = None, - first_name: Optional[str] = None, - last_name: Optional[str] = None, - password: Optional[str] = None, - app_type: Optional[Union[str, "_models.AppType"]] = None, - confirmation: Optional[Union[str, "_models.Confirmation"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState - :keyword note: Optional note about a user set by the administrator. - :paramtype note: str - :keyword identities: Collection of user identities. - :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :keyword email: Email address. Must not be empty and must be unique within the service - instance. - :paramtype email: str - :keyword first_name: First name. - :paramtype first_name: str - :keyword last_name: Last name. - :paramtype last_name: str - :keyword password: User Password. If no value is provided, a default password is generated. - :paramtype password: str - :keyword app_type: Determines the type of application which send the create user request. - Default is legacy portal. Known values are: "portal" and "developerPortal". - :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType - :keyword confirmation: Determines the type of confirmation e-mail that will be sent to the - newly created user. Known values are: "signup" and "invite". - :paramtype confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation - """ - super().__init__(**kwargs) - self.state = state - self.note = note - self.identities = identities - self.email = email - self.first_name = first_name - self.last_name = last_name - self.password = password - self.app_type = app_type - self.confirmation = confirmation - - -class UserIdentityCollection(_serialization.Model): - """List of Users Identity list representation. - - :ivar value: User Identity values. - :vartype value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :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": "[UserIdentityContract]"}, - "count": {"key": "count", "type": "int"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, - *, - value: Optional[List["_models.UserIdentityContract"]] = None, - count: Optional[int] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: User Identity values. - :paramtype value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :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 UserIdentityContract(_serialization.Model): - """User identity details. - - :ivar provider: Identity provider name. - :vartype provider: str - :ivar id: Identifier value within provider. - :vartype id: str - """ - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "id": {"key": "id", "type": "str"}, - } - - def __init__( - self, - *, - provider: Optional[str] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword provider: Identity provider name. - :paramtype provider: str - :keyword id: Identifier value within provider. - :paramtype id: str - """ - super().__init__(**kwargs) - self.provider = provider - self.id = id - - -class UserIdentityProperties(_serialization.Model): - """UserIdentityProperties. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - """ - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword principal_id: The principal id of user assigned identity. - :paramtype principal_id: str - :keyword client_id: The client id of user assigned identity. - :paramtype client_id: str - """ - super().__init__(**kwargs) - self.principal_id = principal_id - self.client_id = client_id - - -class UserTokenParameters(_serialization.Model): - """Get User Token parameters. - - :ivar key_type: The Key to be used to generate token for user. Known values are: "primary" and - "secondary". - :vartype key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :ivar expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The - date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 - standard. - :vartype expiry: ~datetime.datetime - """ - - _attribute_map = { - "key_type": {"key": "properties.keyType", "type": "str"}, - "expiry": {"key": "properties.expiry", "type": "iso-8601"}, - } - - def __init__( - self, - *, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - expiry: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword key_type: The Key to be used to generate token for user. Known values are: "primary" - and "secondary". - :paramtype key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :keyword expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The - date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 - standard. - :paramtype expiry: ~datetime.datetime - """ - super().__init__(**kwargs) - self.key_type = key_type - self.expiry = expiry - - -class UserTokenResult(_serialization.Model): - """Get User Token response details. - - :ivar value: Shared Access Authorization token for the User. - :vartype value: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "str"}, - } - - def __init__(self, *, value: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword value: Shared Access Authorization token for the User. - :paramtype value: str - """ - super().__init__(**kwargs) - self.value = value - - -class UserUpdateParameters(_serialization.Model): - """User update parameters. - - :ivar state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :vartype state: str or ~azure.mgmt.apimanagement.models.UserState - :ivar note: Optional note about a user set by the administrator. - :vartype note: str - :ivar identities: Collection of user identities. - :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :ivar email: Email address. Must not be empty and must be unique within the service instance. - :vartype email: str - :ivar password: User Password. - :vartype password: str - :ivar first_name: First name. - :vartype first_name: str - :ivar last_name: Last name. - :vartype last_name: str - """ - - _validation = { - "email": {"max_length": 254, "min_length": 1}, - "first_name": {"max_length": 100, "min_length": 1}, - "last_name": {"max_length": 100, "min_length": 1}, - } - - _attribute_map = { - "state": {"key": "properties.state", "type": "str"}, - "note": {"key": "properties.note", "type": "str"}, - "identities": {"key": "properties.identities", "type": "[UserIdentityContract]"}, - "email": {"key": "properties.email", "type": "str"}, - "password": {"key": "properties.password", "type": "str"}, - "first_name": {"key": "properties.firstName", "type": "str"}, - "last_name": {"key": "properties.lastName", "type": "str"}, - } - - def __init__( - self, - *, - state: Union[str, "_models.UserState"] = "active", - note: Optional[str] = None, - identities: Optional[List["_models.UserIdentityContract"]] = None, - email: Optional[str] = None, - password: Optional[str] = None, - first_name: Optional[str] = None, - last_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState - :keyword note: Optional note about a user set by the administrator. - :paramtype note: str - :keyword identities: Collection of user identities. - :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :keyword email: Email address. Must not be empty and must be unique within the service - instance. - :paramtype email: str - :keyword password: User Password. - :paramtype password: str - :keyword first_name: First name. - :paramtype first_name: str - :keyword last_name: Last name. - :paramtype last_name: str - """ - super().__init__(**kwargs) - self.state = state - self.note = note - self.identities = identities - self.email = email - self.password = password - self.first_name = first_name - self.last_name = last_name - - -class UserUpdateParametersProperties(UserEntityBaseParameters): - """Parameters supplied to the Update User operation. - - :ivar state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :vartype state: str or ~azure.mgmt.apimanagement.models.UserState - :ivar note: Optional note about a user set by the administrator. - :vartype note: str - :ivar identities: Collection of user identities. - :vartype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :ivar email: Email address. Must not be empty and must be unique within the service instance. - :vartype email: str - :ivar password: User Password. - :vartype password: str - :ivar first_name: First name. - :vartype first_name: str - :ivar last_name: Last name. - :vartype last_name: str - """ - - _validation = { - "email": {"max_length": 254, "min_length": 1}, - "first_name": {"max_length": 100, "min_length": 1}, - "last_name": {"max_length": 100, "min_length": 1}, - } - - _attribute_map = { - "state": {"key": "state", "type": "str"}, - "note": {"key": "note", "type": "str"}, - "identities": {"key": "identities", "type": "[UserIdentityContract]"}, - "email": {"key": "email", "type": "str"}, - "password": {"key": "password", "type": "str"}, - "first_name": {"key": "firstName", "type": "str"}, - "last_name": {"key": "lastName", "type": "str"}, - } - - def __init__( - self, - *, - state: Union[str, "_models.UserState"] = "active", - note: Optional[str] = None, - identities: Optional[List["_models.UserIdentityContract"]] = None, - email: Optional[str] = None, - password: Optional[str] = None, - first_name: Optional[str] = None, - last_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword state: Account state. Specifies whether the user is active or not. Blocked users are - unable to sign into the developer portal or call any APIs of subscribed products. Default state - is Active. Known values are: "active", "blocked", "pending", and "deleted". - :paramtype state: str or ~azure.mgmt.apimanagement.models.UserState - :keyword note: Optional note about a user set by the administrator. - :paramtype note: str - :keyword identities: Collection of user identities. - :paramtype identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :keyword email: Email address. Must not be empty and must be unique within the service - instance. - :paramtype email: str - :keyword password: User Password. - :paramtype password: str - :keyword first_name: First name. - :paramtype first_name: str - :keyword last_name: Last name. - :paramtype last_name: str - """ - super().__init__(state=state, note=note, identities=identities, **kwargs) - self.email = email - self.password = password - self.first_name = first_name - self.last_name = last_name - - -class VirtualNetworkConfiguration(_serialization.Model): - """Configuration of a virtual network to which API Management service is deployed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vnetid: The virtual network ID. This is typically a GUID. Expect a null GUID by default. - :vartype vnetid: str - :ivar subnetname: The name of the subnet. - :vartype subnetname: str - :ivar subnet_resource_id: The full resource ID of a subnet in a virtual network to deploy the - API Management service in. - :vartype subnet_resource_id: str - """ - - _validation = { - "vnetid": {"readonly": True}, - "subnetname": {"readonly": True}, - "subnet_resource_id": { - "pattern": r"^/subscriptions/[^/]*/resourceGroups/[^/]*/providers/Microsoft.(ClassicNetwork|Network)/virtualNetworks/[^/]*/subnets/[^/]*$" - }, - } - - _attribute_map = { - "vnetid": {"key": "vnetid", "type": "str"}, - "subnetname": {"key": "subnetname", "type": "str"}, - "subnet_resource_id": {"key": "subnetResourceId", "type": "str"}, - } - - def __init__(self, *, subnet_resource_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword subnet_resource_id: The full resource ID of a subnet in a virtual network to deploy - the API Management service in. - :paramtype subnet_resource_id: str - """ - super().__init__(**kwargs) - self.vnetid = None - self.subnetname = None - self.subnet_resource_id = subnet_resource_id - - -class WikiCollection(_serialization.Model): - """Paged Wiki list representation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Page values. - :vartype value: list[~azure.mgmt.apimanagement.models.WikiContract] - :ivar next_link: Next page link if any. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[WikiContract]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class WikiContract(ProxyResource): - """Wiki properties. - - 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 documents: Collection wiki documents included into this wiki. - :vartype documents: list[~azure.mgmt.apimanagement.models.WikiDocumentationContract] - """ - - _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"}, - "documents": {"key": "properties.documents", "type": "[WikiDocumentationContract]"}, - } - - def __init__(self, *, documents: Optional[List["_models.WikiDocumentationContract"]] = None, **kwargs: Any) -> None: - """ - :keyword documents: Collection wiki documents included into this wiki. - :paramtype documents: list[~azure.mgmt.apimanagement.models.WikiDocumentationContract] - """ - super().__init__(**kwargs) - self.documents = documents - - -class WikiDocumentationContract(_serialization.Model): - """Wiki documentation details. - - :ivar documentation_id: Documentation Identifier. - :vartype documentation_id: str - """ - - _attribute_map = { - "documentation_id": {"key": "documentationId", "type": "str"}, - } - - def __init__(self, *, documentation_id: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword documentation_id: Documentation Identifier. - :paramtype documentation_id: str - """ - super().__init__(**kwargs) - self.documentation_id = documentation_id - - -class WikiUpdateContract(_serialization.Model): - """Wiki update contract details. - - :ivar documents: Collection wiki documents included into this wiki. - :vartype documents: list[~azure.mgmt.apimanagement.models.WikiDocumentationContract] - """ - - _attribute_map = { - "documents": {"key": "properties.documents", "type": "[WikiDocumentationContract]"}, - } - - def __init__(self, *, documents: Optional[List["_models.WikiDocumentationContract"]] = None, **kwargs: Any) -> None: - """ - :keyword documents: Collection wiki documents included into this wiki. - :paramtype documents: list[~azure.mgmt.apimanagement.models.WikiDocumentationContract] - """ - super().__init__(**kwargs) - 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. - - :ivar name: Common Name of the Certificate. - :vartype name: str - :ivar issuer_certificate_thumbprint: Thumbprint for the Issuer of the Certificate. - :vartype issuer_certificate_thumbprint: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "issuer_certificate_thumbprint": {"key": "issuerCertificateThumbprint", "type": "str"}, - } - - def __init__( - self, *, name: Optional[str] = None, issuer_certificate_thumbprint: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Common Name of the Certificate. - :paramtype name: str - :keyword issuer_certificate_thumbprint: Thumbprint for the Issuer of the Certificate. - :paramtype issuer_certificate_thumbprint: str - """ - super().__init__(**kwargs) - self.name = name - self.issuer_certificate_thumbprint = issuer_certificate_thumbprint diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_patch.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_patch.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): 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 203221376c61..e3b8884a66e9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,172 +12,228 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._api_gateway_operations import ApiGatewayOperations # type: ignore -from ._api_management_gateway_skus_operations import ApiManagementGatewaySkusOperations # type: ignore -from ._all_policies_operations import AllPoliciesOperations # type: ignore -from ._api_operations import ApiOperations # type: ignore -from ._api_revision_operations import ApiRevisionOperations # type: ignore -from ._api_release_operations import ApiReleaseOperations # type: ignore -from ._api_operation_operations import ApiOperationOperations # type: ignore -from ._api_operation_policy_operations import ApiOperationPolicyOperations # type: ignore -from ._tag_operations import TagOperations # type: ignore -from ._graph_ql_api_resolver_operations import GraphQLApiResolverOperations # type: ignore -from ._graph_ql_api_resolver_policy_operations import GraphQLApiResolverPolicyOperations # type: ignore -from ._api_product_operations import ApiProductOperations # type: ignore -from ._api_policy_operations import ApiPolicyOperations # type: ignore -from ._api_schema_operations import ApiSchemaOperations # type: ignore -from ._api_diagnostic_operations import ApiDiagnosticOperations # type: ignore -from ._api_issue_operations import ApiIssueOperations # type: ignore -from ._api_issue_comment_operations import ApiIssueCommentOperations # type: ignore -from ._api_issue_attachment_operations import ApiIssueAttachmentOperations # type: ignore -from ._api_tag_description_operations import ApiTagDescriptionOperations # type: ignore -from ._operation_operations import OperationOperations # type: ignore -from ._api_wiki_operations import ApiWikiOperations # type: ignore -from ._api_wikis_operations import ApiWikisOperations # type: ignore -from ._api_export_operations import ApiExportOperations # type: ignore -from ._api_version_set_operations import ApiVersionSetOperations # type: ignore -from ._authorization_provider_operations import AuthorizationProviderOperations # type: ignore -from ._authorization_operations import AuthorizationOperations # type: ignore -from ._authorization_login_links_operations import AuthorizationLoginLinksOperations # type: ignore -from ._authorization_access_policy_operations import AuthorizationAccessPolicyOperations # type: ignore -from ._authorization_server_operations import AuthorizationServerOperations # type: ignore -from ._backend_operations import BackendOperations # type: ignore -from ._cache_operations import CacheOperations # type: ignore -from ._certificate_operations import CertificateOperations # type: ignore -from ._api_management_client_operations import ApiManagementClientOperationsMixin # type: ignore -from ._content_type_operations import ContentTypeOperations # type: ignore -from ._content_item_operations import ContentItemOperations # type: ignore -from ._deleted_services_operations import DeletedServicesOperations # type: ignore -from ._api_management_operations_operations import ApiManagementOperationsOperations # type: ignore -from ._api_management_service_skus_operations import ApiManagementServiceSkusOperations # type: ignore -from ._api_management_service_operations import ApiManagementServiceOperations # type: ignore -from ._diagnostic_operations import DiagnosticOperations # type: ignore -from ._documentation_operations import DocumentationOperations # type: ignore -from ._email_template_operations import EmailTemplateOperations # type: ignore -from ._api_gateway_config_connection_operations import ApiGatewayConfigConnectionOperations # type: ignore -from ._gateway_operations import GatewayOperations # type: ignore -from ._gateway_hostname_configuration_operations import GatewayHostnameConfigurationOperations # type: ignore -from ._gateway_api_operations import GatewayApiOperations # type: ignore -from ._gateway_certificate_authority_operations import GatewayCertificateAuthorityOperations # type: ignore -from ._group_operations import GroupOperations # type: ignore -from ._group_user_operations import GroupUserOperations # type: ignore -from ._identity_provider_operations import IdentityProviderOperations # type: ignore -from ._issue_operations import IssueOperations # type: ignore -from ._logger_operations import LoggerOperations # type: ignore -from ._named_value_operations import NamedValueOperations # type: ignore -from ._network_status_operations import NetworkStatusOperations # type: ignore -from ._notification_operations import NotificationOperations # type: ignore -from ._notification_recipient_user_operations import NotificationRecipientUserOperations # type: ignore -from ._notification_recipient_email_operations import NotificationRecipientEmailOperations # type: ignore -from ._open_id_connect_provider_operations import OpenIdConnectProviderOperations # type: ignore -from ._outbound_network_dependencies_endpoints_operations import OutboundNetworkDependenciesEndpointsOperations # type: ignore -from ._policy_operations import PolicyOperations # type: ignore -from ._policy_description_operations import PolicyDescriptionOperations # type: ignore -from ._policy_fragment_operations import PolicyFragmentOperations # type: ignore -from ._policy_restriction_operations import PolicyRestrictionOperations # type: ignore -from ._policy_restriction_validations_operations import PolicyRestrictionValidationsOperations # type: ignore -from ._portal_config_operations import PortalConfigOperations # type: ignore -from ._portal_revision_operations import PortalRevisionOperations # type: ignore -from ._portal_settings_operations import PortalSettingsOperations # type: ignore -from ._sign_in_settings_operations import SignInSettingsOperations # type: ignore -from ._sign_up_settings_operations import SignUpSettingsOperations # type: ignore -from ._delegation_settings_operations import DelegationSettingsOperations # type: ignore -from ._private_endpoint_connection_operations import PrivateEndpointConnectionOperations # type: ignore -from ._product_operations import ProductOperations # type: ignore -from ._product_api_operations import ProductApiOperations # type: ignore -from ._product_group_operations import ProductGroupOperations # type: ignore -from ._product_subscriptions_operations import ProductSubscriptionsOperations # type: ignore -from ._product_policy_operations import ProductPolicyOperations # type: ignore -from ._product_wiki_operations import ProductWikiOperations # type: ignore -from ._product_wikis_operations import ProductWikisOperations # type: ignore -from ._product_api_link_operations import ProductApiLinkOperations # type: ignore -from ._product_group_link_operations import ProductGroupLinkOperations # type: ignore -from ._quota_by_counter_keys_operations import QuotaByCounterKeysOperations # type: ignore -from ._quota_by_period_keys_operations import QuotaByPeriodKeysOperations # type: ignore -from ._region_operations import RegionOperations # type: ignore -from ._reports_operations import ReportsOperations # type: ignore -from ._global_schema_operations import GlobalSchemaOperations # type: ignore -from ._tenant_settings_operations import TenantSettingsOperations # type: ignore -from ._api_management_skus_operations import ApiManagementSkusOperations # type: ignore -from ._subscription_operations import SubscriptionOperations # type: ignore -from ._tag_resource_operations import TagResourceOperations # type: ignore -from ._tag_api_link_operations import TagApiLinkOperations # type: ignore -from ._tag_operation_link_operations import TagOperationLinkOperations # type: ignore -from ._tag_product_link_operations import TagProductLinkOperations # type: ignore -from ._tenant_access_operations import TenantAccessOperations # type: ignore -from ._tenant_access_git_operations import TenantAccessGitOperations # type: ignore -from ._tenant_configuration_operations import TenantConfigurationOperations # type: ignore -from ._user_operations import UserOperations # type: ignore -from ._user_group_operations import UserGroupOperations # type: ignore -from ._user_subscription_operations import UserSubscriptionOperations # type: ignore -from ._user_identities_operations import UserIdentitiesOperations # type: ignore -from ._user_confirmation_password_operations import UserConfirmationPasswordOperations # type: ignore -from ._workspace_backend_operations import WorkspaceBackendOperations # type: ignore -from ._workspace_certificate_operations import WorkspaceCertificateOperations # type: ignore -from ._workspace_diagnostic_operations import WorkspaceDiagnosticOperations # type: ignore -from ._workspace_api_diagnostic_operations import WorkspaceApiDiagnosticOperations # type: ignore -from ._api_management_workspace_links_operations import ApiManagementWorkspaceLinksOperations # type: ignore -from ._api_management_workspace_link_operations import ApiManagementWorkspaceLinkOperations # type: ignore -from ._workspace_logger_operations import WorkspaceLoggerOperations # type: ignore -from ._workspace_operations import WorkspaceOperations # type: ignore -from ._workspace_policy_operations import WorkspacePolicyOperations # type: ignore -from ._workspace_named_value_operations import WorkspaceNamedValueOperations # type: ignore -from ._workspace_global_schema_operations import WorkspaceGlobalSchemaOperations # type: ignore -from ._workspace_notification_operations import WorkspaceNotificationOperations # type: ignore -from ._workspace_notification_recipient_user_operations import WorkspaceNotificationRecipientUserOperations # type: ignore -from ._workspace_notification_recipient_email_operations import WorkspaceNotificationRecipientEmailOperations # type: ignore -from ._workspace_policy_fragment_operations import WorkspacePolicyFragmentOperations # type: ignore -from ._workspace_group_operations import WorkspaceGroupOperations # type: ignore -from ._workspace_group_user_operations import WorkspaceGroupUserOperations # type: ignore -from ._workspace_subscription_operations import WorkspaceSubscriptionOperations # type: ignore -from ._workspace_api_version_set_operations import WorkspaceApiVersionSetOperations # type: ignore -from ._workspace_api_operations import WorkspaceApiOperations # type: ignore -from ._workspace_api_revision_operations import WorkspaceApiRevisionOperations # type: ignore -from ._workspace_api_release_operations import WorkspaceApiReleaseOperations # type: ignore -from ._workspace_api_operation_operations import WorkspaceApiOperationOperations # type: ignore -from ._workspace_api_operation_policy_operations import WorkspaceApiOperationPolicyOperations # type: ignore -from ._workspace_api_policy_operations import WorkspaceApiPolicyOperations # type: ignore -from ._workspace_api_schema_operations import WorkspaceApiSchemaOperations # type: ignore -from ._workspace_product_operations import WorkspaceProductOperations # type: ignore -from ._workspace_product_api_link_operations import WorkspaceProductApiLinkOperations # type: ignore -from ._workspace_product_group_link_operations import WorkspaceProductGroupLinkOperations # type: ignore -from ._workspace_product_policy_operations import WorkspaceProductPolicyOperations # type: ignore -from ._workspace_tag_operations import WorkspaceTagOperations # type: ignore -from ._workspace_tag_api_link_operations import WorkspaceTagApiLinkOperations # type: ignore -from ._workspace_tag_operation_link_operations import WorkspaceTagOperationLinkOperations # type: ignore -from ._workspace_tag_product_link_operations import WorkspaceTagProductLinkOperations # type: ignore -from ._workspace_api_export_operations import WorkspaceApiExportOperations # type: ignore -from ._operation_status_operations import OperationStatusOperations # type: ignore -from ._operations_results_operations import OperationsResultsOperations # type: ignore +from ._operations import WorkspaceApiOperations # type: ignore +from ._operations import WorkspaceApiReleaseOperations # type: ignore +from ._operations import WorkspaceApiOperationOperations # type: ignore +from ._operations import GraphQLApiResolverPolicyOperations # type: ignore +from ._operations import ApiPolicyOperations # type: ignore +from ._operations import PolicyOperations # type: ignore +from ._operations import ProductPolicyOperations # type: ignore +from ._operations import WorkspacePolicyOperations # type: ignore +from ._operations import WorkspaceApiOperationPolicyOperations # type: ignore +from ._operations import WorkspaceApiPolicyOperations # type: ignore +from ._operations import WorkspaceProductPolicyOperations # type: ignore +from ._operations import TagOperations # type: ignore +from ._operations import WorkspaceTagOperations # type: ignore +from ._operations import WorkspaceApiSchemaOperations # type: ignore +from ._operations import DiagnosticOperations # type: ignore +from ._operations import WorkspaceDiagnosticOperations # type: ignore +from ._operations import WorkspaceApiDiagnosticOperations # type: ignore +from ._operations import IssueOperations # type: ignore +from ._operations import ProductWikiOperations # type: ignore +from ._operations import WorkspaceApiVersionSetOperations # type: ignore +from ._operations import WorkspaceBackendOperations # type: ignore +from ._operations import WorkspaceCertificateOperations # type: ignore +from ._operations import WorkspaceGroupOperations # type: ignore +from ._operations import WorkspaceLoggerOperations # type: ignore +from ._operations import WorkspaceNamedValueOperations # type: ignore +from ._operations import WorkspaceNotificationOperations # type: ignore +from ._operations import WorkspacePolicyFragmentOperations # type: ignore +from ._operations import SignInSettingsOperations # type: ignore +from ._operations import SignUpSettingsOperations # type: ignore +from ._operations import DelegationSettingsOperations # type: ignore +from ._operations import WorkspaceProductOperations # type: ignore +from ._operations import WorkspaceProductApiLinkOperations # type: ignore +from ._operations import WorkspaceProductGroupLinkOperations # type: ignore +from ._operations import WorkspaceGlobalSchemaOperations # type: ignore +from ._operations import UserSubscriptionOperations # type: ignore +from ._operations import WorkspaceSubscriptionOperations # type: ignore +from ._operations import WorkspaceTagApiLinkOperations # type: ignore +from ._operations import WorkspaceTagOperationLinkOperations # type: ignore +from ._operations import WorkspaceTagProductLinkOperations # type: ignore +from ._operations import ApiManagementOperationsOperations # type: ignore +from ._operations import ApiGatewayOperations # type: ignore +from ._operations import ApiManagementGatewaySkusOperations # type: ignore +from ._operations import ApiOperations # type: ignore +from ._operations import ApiRevisionOperations # type: ignore +from ._operations import ApiProductOperations # type: ignore +from ._operations import OperationOperations # type: ignore +from ._operations import WorkspaceApiRevisionOperations # type: ignore +from ._operations import ApiManagementServiceOperations # type: ignore +from ._operations import AllPoliciesOperations # type: ignore +from ._operations import ApiManagementServiceSkusOperations # type: ignore +from ._operations import NetworkStatusOperations # type: ignore +from ._operations import OutboundNetworkDependenciesEndpointsOperations # type: ignore +from ._operations import PolicyDescriptionOperations # type: ignore +from ._operations import PolicyRestrictionValidationsOperations # type: ignore +from ._operations import PortalSettingsOperations # type: ignore +from ._operations import ProductOperations # type: ignore +from ._operations import QuotaByCounterKeysOperations # type: ignore +from ._operations import QuotaByPeriodKeysOperations # type: ignore +from ._operations import RegionOperations # type: ignore +from ._operations import ReportsOperations # type: ignore +from ._operations import TagResourceOperations # type: ignore +from ._operations import ApiReleaseOperations # type: ignore +from ._operations import ApiOperationOperations # type: ignore +from ._operations import ApiOperationPolicyOperations # type: ignore +from ._operations import GraphQLApiResolverOperations # type: ignore +from ._operations import ApiSchemaOperations # type: ignore +from ._operations import ApiDiagnosticOperations # type: ignore +from ._operations import ApiIssueOperations # type: ignore +from ._operations import ApiIssueCommentOperations # type: ignore +from ._operations import ApiIssueAttachmentOperations # type: ignore +from ._operations import ApiTagDescriptionOperations # type: ignore +from ._operations import ApiWikiOperations # type: ignore +from ._operations import ApiWikisOperations # type: ignore +from ._operations import ProductWikisOperations # type: ignore +from ._operations import ApiToolOperations # type: ignore +from ._operations import ApiVersionSetOperations # type: ignore +from ._operations import AuthorizationProviderOperations # type: ignore +from ._operations import AuthorizationOperations # type: ignore +from ._operations import AuthorizationLoginLinksOperations # type: ignore +from ._operations import AuthorizationAccessPolicyOperations # type: ignore +from ._operations import AuthorizationServerOperations # type: ignore +from ._operations import BackendOperations # type: ignore +from ._operations import CacheOperations # type: ignore +from ._operations import CertificateOperations # type: ignore +from ._operations import ContentTypeOperations # type: ignore +from ._operations import ContentItemOperations # type: ignore +from ._operations import DeletedServicesOperations # type: ignore +from ._operations import DocumentationOperations # type: ignore +from ._operations import EmailTemplateOperations # type: ignore +from ._operations import ApiGatewayConfigConnectionOperations # type: ignore +from ._operations import ApiGatewayHostnameBindingOperations # type: ignore +from ._operations import GatewayOperations # type: ignore +from ._operations import GatewayApiOperations # type: ignore +from ._operations import GatewayHostnameConfigurationOperations # type: ignore +from ._operations import GatewayCertificateAuthorityOperations # type: ignore +from ._operations import GroupOperations # type: ignore +from ._operations import GroupUserOperations # type: ignore +from ._operations import WorkspaceGroupUserOperations # type: ignore +from ._operations import IdentityProviderOperations # type: ignore +from ._operations import LoggerOperations # type: ignore +from ._operations import NamedValueOperations # type: ignore +from ._operations import NotificationOperations # type: ignore +from ._operations import NotificationRecipientUserOperations # type: ignore +from ._operations import NotificationRecipientEmailOperations # type: ignore +from ._operations import WorkspaceNotificationRecipientUserOperations # type: ignore +from ._operations import WorkspaceNotificationRecipientEmailOperations # type: ignore +from ._operations import OpenIdConnectProviderOperations # type: ignore +from ._operations import PolicyFragmentOperations # type: ignore +from ._operations import PolicyRestrictionOperations # type: ignore +from ._operations import PortalConfigOperations # type: ignore +from ._operations import ClientApplicationOperations # type: ignore +from ._operations import ClientApplicationProductLinkOperations # type: ignore +from ._operations import PortalRevisionOperations # type: ignore +from ._operations import PrivateEndpointConnectionOperations # type: ignore +from ._operations import ProductApiOperations # type: ignore +from ._operations import ProductGroupOperations # type: ignore +from ._operations import ProductSubscriptionsOperations # type: ignore +from ._operations import ProductApiLinkOperations # type: ignore +from ._operations import ProductGroupLinkOperations # type: ignore +from ._operations import GlobalSchemaOperations # type: ignore +from ._operations import TenantSettingsOperations # type: ignore +from ._operations import SubscriptionOperations # type: ignore +from ._operations import TagApiLinkOperations # type: ignore +from ._operations import TagOperationLinkOperations # type: ignore +from ._operations import TagProductLinkOperations # type: ignore +from ._operations import TenantAccessOperations # type: ignore +from ._operations import TenantAccessGitOperations # type: ignore +from ._operations import TenantConfigurationOperations # type: ignore +from ._operations import UserOperations # type: ignore +from ._operations import UserGroupOperations # type: ignore +from ._operations import UserIdentitiesOperations # type: ignore +from ._operations import UserConfirmationPasswordOperations # type: ignore +from ._operations import ApiManagementWorkspaceLinkOperations # type: ignore +from ._operations import ApiManagementWorkspaceLinksOperations # type: ignore +from ._operations import WorkspaceOperations # type: ignore +from ._operations import ApiExportOperations # type: ignore +from ._operations import ApiManagementSkusOperations # type: ignore +from ._operations import WorkspaceApiExportOperations # type: ignore +from ._operations import OperationStatusOperations # type: ignore +from ._operations import OperationsResultsOperations # type: ignore +from ._operations import _ApiManagementClientOperationsMixin # type: ignore # pylint: disable=unused-import from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "WorkspaceApiOperations", + "WorkspaceApiReleaseOperations", + "WorkspaceApiOperationOperations", + "GraphQLApiResolverPolicyOperations", + "ApiPolicyOperations", + "PolicyOperations", + "ProductPolicyOperations", + "WorkspacePolicyOperations", + "WorkspaceApiOperationPolicyOperations", + "WorkspaceApiPolicyOperations", + "WorkspaceProductPolicyOperations", + "TagOperations", + "WorkspaceTagOperations", + "WorkspaceApiSchemaOperations", + "DiagnosticOperations", + "WorkspaceDiagnosticOperations", + "WorkspaceApiDiagnosticOperations", + "IssueOperations", + "ProductWikiOperations", + "WorkspaceApiVersionSetOperations", + "WorkspaceBackendOperations", + "WorkspaceCertificateOperations", + "WorkspaceGroupOperations", + "WorkspaceLoggerOperations", + "WorkspaceNamedValueOperations", + "WorkspaceNotificationOperations", + "WorkspacePolicyFragmentOperations", + "SignInSettingsOperations", + "SignUpSettingsOperations", + "DelegationSettingsOperations", + "WorkspaceProductOperations", + "WorkspaceProductApiLinkOperations", + "WorkspaceProductGroupLinkOperations", + "WorkspaceGlobalSchemaOperations", + "UserSubscriptionOperations", + "WorkspaceSubscriptionOperations", + "WorkspaceTagApiLinkOperations", + "WorkspaceTagOperationLinkOperations", + "WorkspaceTagProductLinkOperations", + "ApiManagementOperationsOperations", "ApiGatewayOperations", "ApiManagementGatewaySkusOperations", - "AllPoliciesOperations", "ApiOperations", "ApiRevisionOperations", + "ApiProductOperations", + "OperationOperations", + "WorkspaceApiRevisionOperations", + "ApiManagementServiceOperations", + "AllPoliciesOperations", + "ApiManagementServiceSkusOperations", + "NetworkStatusOperations", + "OutboundNetworkDependenciesEndpointsOperations", + "PolicyDescriptionOperations", + "PolicyRestrictionValidationsOperations", + "PortalSettingsOperations", + "ProductOperations", + "QuotaByCounterKeysOperations", + "QuotaByPeriodKeysOperations", + "RegionOperations", + "ReportsOperations", + "TagResourceOperations", "ApiReleaseOperations", "ApiOperationOperations", "ApiOperationPolicyOperations", - "TagOperations", "GraphQLApiResolverOperations", - "GraphQLApiResolverPolicyOperations", - "ApiProductOperations", - "ApiPolicyOperations", "ApiSchemaOperations", "ApiDiagnosticOperations", "ApiIssueOperations", "ApiIssueCommentOperations", "ApiIssueAttachmentOperations", "ApiTagDescriptionOperations", - "OperationOperations", "ApiWikiOperations", "ApiWikisOperations", - "ApiExportOperations", + "ProductWikisOperations", + "ApiToolOperations", "ApiVersionSetOperations", "AuthorizationProviderOperations", "AuthorizationOperations", @@ -187,63 +243,44 @@ "BackendOperations", "CacheOperations", "CertificateOperations", - "ApiManagementClientOperationsMixin", "ContentTypeOperations", "ContentItemOperations", "DeletedServicesOperations", - "ApiManagementOperationsOperations", - "ApiManagementServiceSkusOperations", - "ApiManagementServiceOperations", - "DiagnosticOperations", "DocumentationOperations", "EmailTemplateOperations", "ApiGatewayConfigConnectionOperations", + "ApiGatewayHostnameBindingOperations", "GatewayOperations", - "GatewayHostnameConfigurationOperations", "GatewayApiOperations", + "GatewayHostnameConfigurationOperations", "GatewayCertificateAuthorityOperations", "GroupOperations", "GroupUserOperations", + "WorkspaceGroupUserOperations", "IdentityProviderOperations", - "IssueOperations", "LoggerOperations", "NamedValueOperations", - "NetworkStatusOperations", "NotificationOperations", "NotificationRecipientUserOperations", "NotificationRecipientEmailOperations", + "WorkspaceNotificationRecipientUserOperations", + "WorkspaceNotificationRecipientEmailOperations", "OpenIdConnectProviderOperations", - "OutboundNetworkDependenciesEndpointsOperations", - "PolicyOperations", - "PolicyDescriptionOperations", "PolicyFragmentOperations", "PolicyRestrictionOperations", - "PolicyRestrictionValidationsOperations", "PortalConfigOperations", + "ClientApplicationOperations", + "ClientApplicationProductLinkOperations", "PortalRevisionOperations", - "PortalSettingsOperations", - "SignInSettingsOperations", - "SignUpSettingsOperations", - "DelegationSettingsOperations", "PrivateEndpointConnectionOperations", - "ProductOperations", "ProductApiOperations", "ProductGroupOperations", "ProductSubscriptionsOperations", - "ProductPolicyOperations", - "ProductWikiOperations", - "ProductWikisOperations", "ProductApiLinkOperations", "ProductGroupLinkOperations", - "QuotaByCounterKeysOperations", - "QuotaByPeriodKeysOperations", - "RegionOperations", - "ReportsOperations", "GlobalSchemaOperations", "TenantSettingsOperations", - "ApiManagementSkusOperations", "SubscriptionOperations", - "TagResourceOperations", "TagApiLinkOperations", "TagOperationLinkOperations", "TagProductLinkOperations", @@ -252,43 +289,13 @@ "TenantConfigurationOperations", "UserOperations", "UserGroupOperations", - "UserSubscriptionOperations", "UserIdentitiesOperations", "UserConfirmationPasswordOperations", - "WorkspaceBackendOperations", - "WorkspaceCertificateOperations", - "WorkspaceDiagnosticOperations", - "WorkspaceApiDiagnosticOperations", - "ApiManagementWorkspaceLinksOperations", "ApiManagementWorkspaceLinkOperations", - "WorkspaceLoggerOperations", + "ApiManagementWorkspaceLinksOperations", "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", + "ApiExportOperations", + "ApiManagementSkusOperations", "WorkspaceApiExportOperations", "OperationStatusOperations", "OperationsResultsOperations", 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 deleted file mode 100644 index 9b59982cf647..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_all_policies_operations.py +++ /dev/null @@ -1,182 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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 = { - 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 deleted file mode 100644 index 6382e351679b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_diagnostic_operations.py +++ /dev/null @@ -1,1020 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 ApiDiagnosticOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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_service( - self, - resource_group_name: str, - service_name: 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - api_id: str, - diagnostic_id: str, - if_match: str, - parameters: _models.DiagnosticContract, - *, - 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 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.DiagnosticContract - :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, - 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 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, - api_id: str, - diagnostic_id: str, - if_match: str, - parameters: Union[_models.DiagnosticContract, 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 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 DiagnosticContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract 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 = { - 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_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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, 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 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 = { - 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, - 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/_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py deleted file mode 100644 index 013cf8f4a80c..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_export_operations.py +++ /dev/null @@ -1,183 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 ApiExportOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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. 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 - :return: ApiExportResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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/_api_gateway_config_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_config_connection_operations.py deleted file mode 100644 index 682fc3ca9df0..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_config_connection_operations.py +++ /dev/null @@ -1,749 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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": "azure-async-operation"}, **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 = { - 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 deleted file mode 100644 index d8e350a3df4a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_gateway_operations.py +++ /dev/null @@ -1,1020 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index ca4c33388c87..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_attachment_operations.py +++ /dev/null @@ -1,861 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - api_id: str, - issue_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_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, - api_id: str, - issue_id: str, - attachment_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "attachmentId": _SERIALIZER.url( - "attachment_id", attachment_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, - api_id: str, - issue_id: str, - attachment_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "attachmentId": _SERIALIZER.url( - "attachment_id", attachment_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, - api_id: str, - issue_id: str, - attachment_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-05-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}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "attachmentId": _SERIALIZER.url( - "attachment_id", attachment_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_delete_request( - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - attachment_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "attachmentId": _SERIALIZER.url( - "attachment_id", attachment_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") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class ApiIssueAttachmentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_issue_attachment` 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, - api_id: str, - issue_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.IssueAttachmentContract"]: - """Lists all attachments for the Issue associated with 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | - 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 IssueAttachmentContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentContract] - :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.IssueAttachmentCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_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("IssueAttachmentCollection", 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, api_id: str, issue_id: str, attachment_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the issue Attachment 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_id, - attachment_id=attachment_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, api_id: str, issue_id: str, attachment_id: str, **kwargs: Any - ) -> _models.IssueAttachmentContract: - """Gets the details of the issue Attachment 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_id: str - :return: IssueAttachmentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueAttachmentContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - attachment_id=attachment_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("IssueAttachmentContract", 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, - api_id: str, - issue_id: str, - attachment_id: str, - parameters: _models.IssueAttachmentContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueAttachmentContract: - """Creates a new Attachment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :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: IssueAttachmentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - attachment_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueAttachmentContract: - """Creates a new Attachment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_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: IssueAttachmentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - attachment_id: str, - parameters: Union[_models.IssueAttachmentContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.IssueAttachmentContract: - """Creates a new Attachment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_id: str - :param parameters: Create parameters. Is either a IssueAttachmentContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract 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: IssueAttachmentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueAttachmentContract] = 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, "IssueAttachmentContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - attachment_id=attachment_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("IssueAttachmentContract", 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, - api_id: str, - issue_id: str, - attachment_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the specified comment from an Issue. - - :param resource_group_name: The name of the resource group. The name is 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 identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be unique in the current - Issue. Required. - :type attachment_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 = { - 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, - api_id=api_id, - issue_id=issue_id, - attachment_id=attachment_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/_api_issue_comment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py deleted file mode 100644 index db6f536c5f4a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_comment_operations.py +++ /dev/null @@ -1,861 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - api_id: str, - issue_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_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, - api_id: str, - issue_id: str, - comment_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "commentId": _SERIALIZER.url( - "comment_id", comment_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, - api_id: str, - issue_id: str, - comment_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "commentId": _SERIALIZER.url( - "comment_id", comment_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, - api_id: str, - issue_id: str, - comment_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-05-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}/apis/{apiId}/issues/{issueId}/comments/{commentId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "commentId": _SERIALIZER.url( - "comment_id", comment_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_delete_request( - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - comment_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "commentId": _SERIALIZER.url( - "comment_id", comment_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") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class ApiIssueCommentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_issue_comment` 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, - api_id: str, - issue_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.IssueCommentContract"]: - """Lists all comments for the Issue associated with 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | - 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 IssueCommentContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueCommentContract] - :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.IssueCommentCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_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("IssueCommentCollection", 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, api_id: str, issue_id: str, comment_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the issue Comment 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_id, - comment_id=comment_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, api_id: str, issue_id: str, comment_id: str, **kwargs: Any - ) -> _models.IssueCommentContract: - """Gets the details of the issue Comment 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_id: str - :return: IssueCommentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueCommentContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - comment_id=comment_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("IssueCommentContract", 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, - api_id: str, - issue_id: str, - comment_id: str, - parameters: _models.IssueCommentContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueCommentContract: - """Creates a new Comment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract - :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: IssueCommentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - comment_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueCommentContract: - """Creates a new Comment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_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: IssueCommentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - comment_id: str, - parameters: Union[_models.IssueCommentContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.IssueCommentContract: - """Creates a new Comment for the Issue in 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_id: str - :param parameters: Create parameters. Is either a IssueCommentContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract 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: IssueCommentContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueCommentContract] = 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, "IssueCommentContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - comment_id=comment_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("IssueCommentContract", 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, - api_id: str, - issue_id: str, - comment_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the specified comment from an Issue. - - :param resource_group_name: The name of the resource group. The name is 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 identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. - Required. - :type comment_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 = { - 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, - api_id=api_id, - issue_id=issue_id, - comment_id=comment_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/_api_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py deleted file mode 100644 index 1240eed0b38d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_issue_operations.py +++ /dev/null @@ -1,1050 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - api_id: str, - subscription_id: str, - *, - filter: Optional[str] = None, - expand_comments_attachments: Optional[bool] = 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues", - ) # 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])?$", - ), - "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 expand_comments_attachments is not None: - _params["expandCommentsAttachments"] = _SERIALIZER.query( - "expand_comments_attachments", expand_comments_attachments, "bool" - ) - 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, api_id: str, issue_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_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, - api_id: str, - issue_id: str, - subscription_id: str, - *, - expand_comments_attachments: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_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 expand_comments_attachments is not None: - _params["expandCommentsAttachments"] = _SERIALIZER.query( - "expand_comments_attachments", expand_comments_attachments, "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_create_or_update_request( - resource_group_name: str, - service_name: str, - api_id: str, - issue_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-05-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}/apis/{apiId}/issues/{issueId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_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, - api_id: str, - issue_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-05-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}/apis/{apiId}/issues/{issueId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_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, - api_id: str, - issue_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=80, min_length=1), - "issueId": _SERIALIZER.url( - "issue_id", issue_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") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class ApiIssueOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_issue` 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, - api_id: str, - filter: Optional[str] = None, - expand_comments_attachments: Optional[bool] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.IssueContract"]: - """Lists all issues associated with 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 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 |
| userId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | - filter | eq | |
. Default value is None. - :type filter: str - :param expand_comments_attachments: Expand the comment attachments. Default value is None. - :type expand_comments_attachments: bool - :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 IssueContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueContract] - :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.IssueCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - api_id=api_id, - subscription_id=self._config.subscription_id, - filter=filter, - expand_comments_attachments=expand_comments_attachments, - 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("IssueCollection", 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, api_id: str, issue_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - issue_id=issue_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, - api_id: str, - issue_id: str, - expand_comments_attachments: Optional[bool] = None, - **kwargs: Any - ) -> _models.IssueContract: - """Gets the details of the Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param expand_comments_attachments: Expand the comment attachments. Default value is None. - :type expand_comments_attachments: bool - :return: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_id, - subscription_id=self._config.subscription_id, - expand_comments_attachments=expand_comments_attachments, - 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("IssueContract", 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, - api_id: str, - issue_id: str, - parameters: _models.IssueContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueContract: - """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueContract - :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: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueContract: - """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - parameters: Union[_models.IssueContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.IssueContract: - """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :param parameters: Create parameters. Is either a IssueContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueContract 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: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueContract] = 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, "IssueContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_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("IssueContract", 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, - api_id: str, - issue_id: str, - if_match: str, - parameters: _models.IssueUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueContract: - """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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.IssueUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IssueContract: - """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - issue_id: str, - if_match: str, - parameters: Union[_models.IssueUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.IssueContract: - """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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 IssueUpdateContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract or IO[bytes] - :return: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueContract] = 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, "IssueUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - issue_id=issue_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("IssueContract", 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, api_id: str, issue_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_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 = { - 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, - api_id=api_id, - issue_id=issue_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/_api_management_client_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py deleted file mode 100644 index 166504f134dd..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_client_operations.py +++ /dev/null @@ -1,295 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, Iterator, Optional, TypeVar, Union, cast, overload - -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 -from .._vendor import ApiManagementClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_perform_connectivity_check_async_request( # pylint: disable=name-too-long - 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-05-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}/connectivityCheck", - ) # 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 - 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) - - -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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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(connectivity_check_request_params, (IOBase, bytes)): - _content = connectivity_check_request_params - else: - _json = self._serialize.body(connectivity_check_request_params, "ConnectivityCheckRequest") - - _request = build_perform_connectivity_check_async_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.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_perform_connectivity_check_async( - self, - resource_group_name: str, - service_name: str, - connectivity_check_request_params: _models.ConnectivityCheckRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ConnectivityCheckResponse]: - """Performs a connectivity check between the API Management service and a given destination, and - returns metrics for the connection, as well as errors encountered while trying to establish it. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param connectivity_check_request_params: Connectivity Check request parameters. Required. - :type connectivity_check_request_params: - ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest - :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 ConnectivityCheckResponse or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_perform_connectivity_check_async( - self, - resource_group_name: str, - service_name: str, - connectivity_check_request_params: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ConnectivityCheckResponse]: - """Performs a connectivity check between the API Management service and a given destination, and - returns metrics for the connection, as well as errors encountered while trying to establish it. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param connectivity_check_request_params: Connectivity Check request parameters. Required. - :type connectivity_check_request_params: 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 ConnectivityCheckResponse or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_perform_connectivity_check_async( - self, - resource_group_name: str, - service_name: str, - connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ConnectivityCheckResponse]: - """Performs a connectivity check between the API Management service and a given destination, and - returns metrics for the connection, as well as errors encountered while trying to establish it. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param connectivity_check_request_params: Connectivity Check request parameters. Is either a - ConnectivityCheckRequest type or a IO[bytes] type. Required. - :type connectivity_check_request_params: - ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest or IO[bytes] - :return: An instance of LROPoller that returns either ConnectivityCheckResponse or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] - :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.ConnectivityCheckResponse] = 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._perform_connectivity_check_async_initial( - resource_group_name=resource_group_name, - service_name=service_name, - connectivity_check_request_params=connectivity_check_request_params, - 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("ConnectivityCheckResponse", 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.ConnectivityCheckResponse].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConnectivityCheckResponse]( - 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_management_gateway_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_gateway_skus_operations.py deleted file mode 100644 index b87383018c70..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_gateway_skus_operations.py +++ /dev/null @@ -1,185 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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 = { - 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 deleted file mode 100644 index b2858e7b348f..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py +++ /dev/null @@ -1,151 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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(**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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.ApiManagement/operations") - - # 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 ApiManagementOperationsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_management_operations` 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, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available REST API operations of the Microsoft.ApiManagement provider. - - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.Operation] - :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.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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( - 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("OperationListResult", 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_service_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py deleted file mode 100644 index 564425da4fce..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_operations.py +++ /dev/null @@ -1,2352 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_restore_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-05-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}/restore", - ) # 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 - 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_backup_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-05-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}/backup", - ) # 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 - 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_create_or_update_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-05-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}", - ) # 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 - 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, 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-05-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}", - ) # 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 - 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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", - ) # 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) - - -def build_delete_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}", - ) # 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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_migrate_to_stv2_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-05-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}/migrateToStv2", - ) # 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 - 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_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service", - ) # 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-05-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"), - } - - _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_sso_token_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken", - ) # 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) - - -def build_check_name_availability_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-05-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}/providers/Microsoft.ApiManagement/checkNameAvailability" - ) # pylint: disable=line-too-long - 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 - 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_get_domain_ownership_identifier_request( # pylint: disable=name-too-long - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier" - ) # pylint: disable=line-too-long - 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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_apply_network_configuration_updates_request( # pylint: disable=name-too-long - 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-05-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}/applynetworkconfigurationupdates", - ) # 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 - 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) - - -class ApiManagementServiceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_management_service` 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 _restore_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, "ApiManagementServiceBackupRestoreParameters") - - _request = build_restore_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.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_restore( - self, - resource_group_name: str, - service_name: str, - parameters: _models.ApiManagementServiceBackupRestoreParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Restores a backup of an API Management service created using the ApiManagementService_Backup - operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup - operation. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - :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_restore( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Restores a backup of an API Management service created using the ApiManagementService_Backup - operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup - 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 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_restore( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Restores a backup of an API Management service created using the ApiManagementService_Backup - operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup - operation. Is either a ApiManagementServiceBackupRestoreParameters type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - 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 = case_insensitive_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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._restore_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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _backup_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, "ApiManagementServiceBackupRestoreParameters") - - _request = build_backup_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.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_backup( - self, - resource_group_name: str, - service_name: str, - parameters: _models.ApiManagementServiceBackupRestoreParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - :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_backup( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup 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 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_backup( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Is either - a ApiManagementServiceBackupRestoreParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - 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 = case_insensitive_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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._backup_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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _create_or_update_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceResource, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, "ApiManagementServiceResource") - - _request = build_create_or_update_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.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, - service_name: str, - parameters: _models.ApiManagementServiceResource, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource - :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_create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service 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 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_create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceResource, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. - Is either a ApiManagementServiceResource type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource 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 = case_insensitive_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) - 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, - 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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, "ApiManagementServiceUpdateParameters") - - _request = build_update_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.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, - service_name: str, - parameters: _models.ApiManagementServiceUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters - :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_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service 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 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_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.ApiManagementServiceUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. - Is either a ApiManagementServiceUpdateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters 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 = case_insensitive_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) - 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, - 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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ApiManagementServiceResource: - """Gets an API Management service 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 - :return: ApiManagementServiceResource or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ApiManagementServiceResource] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("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) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - 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, 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, service_name: str, **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Deletes an existing 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 - :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 {} - _params = 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_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("ApiManagementServiceResource", 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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ApiManagementServiceResource]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _migrate_to_stv2_initial( - self, - resource_group_name: str, - service_name: str, - parameters: Optional[Union[_models.MigrateToStv2Contract, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: - 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.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_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, - 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 - 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. 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 = case_insensitive_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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - 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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ApiManagementServiceResource]( - 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.ApiManagementServiceResource"]: - """List all API Management services 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 ApiManagementServiceResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :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.ApiManagementServiceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("ApiManagementServiceListResult", 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.ApiManagementServiceResource"]: - """Lists all API Management services within an Azure subscription. - - :return: An iterator like instance of either ApiManagementServiceResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :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.ApiManagementServiceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("ApiManagementServiceListResult", 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_sso_token( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.ApiManagementServiceGetSsoTokenResult: - """Gets the Single-Sign-On token for the API Management Service which is 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 - :return: ApiManagementServiceGetSsoTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ApiManagementServiceGetSsoTokenResult] = kwargs.pop("cls", None) - - _request = build_get_sso_token_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) - - _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("ApiManagementServiceGetSsoTokenResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def check_name_availability( - self, - parameters: _models.ApiManagementServiceCheckNameAvailabilityParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiManagementServiceNameAvailabilityResult: - """Checks availability and correctness of a name for an API Management service. - - :param parameters: Parameters supplied to the CheckNameAvailability operation. Required. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ApiManagementServiceNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ApiManagementServiceNameAvailabilityResult: - """Checks availability and correctness of a name for an API Management service. - - :param parameters: Parameters supplied to the CheckNameAvailability 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: ApiManagementServiceNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, parameters: Union[_models.ApiManagementServiceCheckNameAvailabilityParameters, IO[bytes]], **kwargs: Any - ) -> _models.ApiManagementServiceNameAvailabilityResult: - """Checks availability and correctness of a name for an API Management service. - - :param parameters: Parameters supplied to the CheckNameAvailability operation. Is either a - ApiManagementServiceCheckNameAvailabilityParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters or - IO[bytes] - :return: ApiManagementServiceNameAvailabilityResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ApiManagementServiceNameAvailabilityResult] = 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, "ApiManagementServiceCheckNameAvailabilityParameters") - - _request = build_check_name_availability_request( - 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("ApiManagementServiceNameAvailabilityResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_domain_ownership_identifier( - self, **kwargs: Any - ) -> _models.ApiManagementServiceGetDomainOwnershipIdentifierResult: - """Get the custom domain ownership identifier for an API Management service. - - :return: ApiManagementServiceGetDomainOwnershipIdentifierResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ApiManagementServiceGetDomainOwnershipIdentifierResult] = kwargs.pop("cls", None) - - _request = build_get_domain_ownership_identifier_request( - 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( - "ApiManagementServiceGetDomainOwnershipIdentifierResult", pipeline_response.http_response - ) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _apply_network_configuration_updates_initial( # pylint: disable=name-too-long - self, - resource_group_name: str, - service_name: str, - parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: - if parameters is not None: - _json = self._serialize.body(parameters, "ApiManagementServiceApplyNetworkConfigurationParameters") - else: - _json = None - - _request = build_apply_network_configuration_updates_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.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_apply_network_configuration_updates( # pylint: disable=name-too-long - self, - resource_group_name: str, - service_name: str, - parameters: Optional[_models.ApiManagementServiceApplyNetworkConfigurationParameters] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated - DNS changes. - - :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the - parameters are empty, all the regions in which the Api Management service is deployed will be - updated sequentially without incurring downtime in the region. Default value is None. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters - :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_apply_network_configuration_updates( # pylint: disable=name-too-long - self, - resource_group_name: str, - service_name: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated - DNS changes. - - :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the - parameters are empty, all the regions in which the Api Management service is deployed will be - updated sequentially without incurring downtime in the region. 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_apply_network_configuration_updates( # pylint: disable=name-too-long - self, - resource_group_name: str, - service_name: str, - parameters: Optional[Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, IO[bytes]]] = None, - **kwargs: Any - ) -> LROPoller[_models.ApiManagementServiceResource]: - """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated - DNS changes. - - :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the - parameters are empty, all the regions in which the Api Management service is deployed will be - updated sequentially without incurring downtime in the region. Is either a - ApiManagementServiceApplyNetworkConfigurationParameters type or a IO[bytes] type. Default value - is None. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters 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 = case_insensitive_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) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._apply_network_configuration_updates_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.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.ApiManagementServiceResource].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ApiManagementServiceResource]( - 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_management_service_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py deleted file mode 100644 index 8436ddd7660d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_service_skus_operations.py +++ /dev/null @@ -1,184 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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_service_skus_request( # pylint: disable=name-too-long - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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 - ), - "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 ApiManagementServiceSkusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_management_service_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_service_skus( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceSkuResult"]: - """Gets available SKUs for API Management service. - - Gets all available SKU for a given 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 - :return: An iterator like instance of either ResourceSkuResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResult] - :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.ResourceSkuResults] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_service_skus_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("ResourceSkuResults", 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_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py deleted file mode 100644 index 6eb949b73294..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_skus_operations.py +++ /dev/null @@ -1,157 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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(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-05-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"), - } - - _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 ApiManagementSkusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_management_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(self, **kwargs: Any) -> Iterable["_models.ApiManagementSku"]: - """Gets the list of Microsoft.ApiManagement SKUs available for your Subscription. - - :return: An iterator like instance of either ApiManagementSku or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSku] - :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.ApiManagementSkusResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("ApiManagementSkusResult", 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_workspace_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_link_operations.py deleted file mode 100644 index 05766f2d33a1..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_link_operations.py +++ /dev/null @@ -1,161 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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 = { - 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 deleted file mode 100644 index 890288f7f54e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_workspace_links_operations.py +++ /dev/null @@ -1,184 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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 = { - 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 deleted file mode 100644 index bf99fb103f25..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py +++ /dev/null @@ -1,1021 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 ApiOperationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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/_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py deleted file mode 100644 index 122f8e1598e6..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_policy_operations.py +++ /dev/null @@ -1,792 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 ApiOperationPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, api_id: str, operation_id: str, **kwargs: Any - ) -> _models.PolicyCollection: - """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 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: PolicyCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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/_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py deleted file mode 100644 index 0ee0b4e75196..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operations.py +++ /dev/null @@ -1,1303 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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) - - -def build_list_by_tags_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - include_not_tagged_apis: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags", - ) # 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) - if include_not_tagged_apis is not None: - _params["includeNotTaggedApis"] = _SERIALIZER.query("include_not_tagged_apis", include_not_tagged_apis, "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) - - -class ApiOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - api_id: str, - parameters: Union[_models.ApiCreateOrUpdateParameter, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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 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, - 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 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 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, - 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 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 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, - 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, - api_id: str, - if_match: str, - parameters: _models.ApiUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiContract: - """Updates 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 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, - api_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiContract: - """Updates 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 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, - api_id: str, - if_match: str, - parameters: Union[_models.ApiUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.ApiContract: - """Updates 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 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 = { - 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, - 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 - - def _delete_initial( - self, - resource_group_name: str, - service_name: str, - api_id: str, - if_match: str, - delete_revisions: Optional[bool] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - service_name=service_name, - 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) - - _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")) - 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_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( - self, - resource_group_name: str, - service_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - include_not_tagged_apis: Optional[bool] = None, - **kwargs: Any - ) -> Iterable["_models.TagResourceContract"]: - """Lists a collection of apis associated with tags. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| - displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| path | 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 |
| isCurrent | 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 - :param include_not_tagged_apis: Include not tagged APIs. Default value is None. - :type include_not_tagged_apis: bool - :return: An iterator like instance of either TagResourceContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :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.TagResourceCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_tags_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - include_not_tagged_apis=include_not_tagged_apis, - 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("TagResourceCollection", 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_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py deleted file mode 100644 index 2fb3f8fbb747..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_policy_operations.py +++ /dev/null @@ -1,754 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop( - "Accept", - "application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml", - ) - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 ApiPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, api_id: str, **kwargs: Any - ) -> _models.PolicyCollection: - """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 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: PolicyCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, 200]: - map_error(status_code=response.status_code, 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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/_api_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py deleted file mode 100644 index 877f9f7ef8c8..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_product_operations.py +++ /dev/null @@ -1,220 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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_apis_request( - resource_group_name: str, - service_name: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/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])?$", - ), - "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 ApiProductOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_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_apis( - self, - resource_group_name: str, - service_name: str, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ProductContract"]: - """Lists all Products, which the API is part of. - - :param resource_group_name: The name of the resource group. The name is 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 identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| 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 - :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 = { - 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_apis_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("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) 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 deleted file mode 100644 index 171b0ace798e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_release_operations.py +++ /dev/null @@ -1,1022 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 ApiReleaseOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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/_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py deleted file mode 100644 index 31b395023920..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_revision_operations.py +++ /dev/null @@ -1,220 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 ApiRevisionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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/_api_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py deleted file mode 100644 index a7e511983205..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_schema_operations.py +++ /dev/null @@ -1,883 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 ApiSchemaOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - api_id: str, - schema_id: str, - parameters: Union[_models.SchemaContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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, - 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 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, - 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 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, - 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, - 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 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 = { - 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, - 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/_api_tag_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py deleted file mode 100644 index 33bdc6b622b3..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_tag_description_operations.py +++ /dev/null @@ -1,810 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions", - ) # 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])?$", - ), - "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, - api_id: str, - tag_description_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "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"), - } - - _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, - api_id: str, - tag_description_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "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"), - } - - _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, - api_id: str, - tag_description_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-05-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}/apis/{apiId}/tagDescriptions/{tagDescriptionId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "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"), - } - - _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, - api_id: str, - tag_description_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}", - ) # 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])?$", - ), - "apiId": _SERIALIZER.url("api_id", api_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$"), - "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"), - } - - _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 ApiTagDescriptionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_tag_description` 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, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.TagDescriptionContract"]: - """Lists all Tags descriptions in scope of API. Model similar to swagger - tagDescription is - defined on API level but tag may be assigned to the Operations. - - :param resource_group_name: The name of the resource group. The name is 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| 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 TagDescriptionContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionContract] - :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.TagDescriptionCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("TagDescriptionCollection", 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, api_id: str, tag_description_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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - tag_description_id=tag_description_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, api_id: str, tag_description_id: str, **kwargs: Any - ) -> _models.TagDescriptionContract: - """Get Tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_id: str - :return: TagDescriptionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.TagDescriptionContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - tag_description_id=tag_description_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("TagDescriptionContract", 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, - api_id: str, - tag_description_id: str, - parameters: _models.TagDescriptionCreateParameters, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TagDescriptionContract: - """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters - :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: TagDescriptionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - tag_description_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.TagDescriptionContract: - """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_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: TagDescriptionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - tag_description_id: str, - parameters: Union[_models.TagDescriptionCreateParameters, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.TagDescriptionContract: - """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_id: str - :param parameters: Create parameters. Is either a TagDescriptionCreateParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters 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: TagDescriptionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.TagDescriptionContract] = 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, "TagDescriptionCreateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - tag_description_id=tag_description_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("TagDescriptionContract", 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, - api_id: str, - tag_description_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Delete tag description 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for - API/Tag association. Based on API and Tag names. Required. - :type tag_description_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 = { - 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, - api_id=api_id, - tag_description_id=tag_description_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/_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py deleted file mode 100644 index ce4c938f9654..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_version_set_operations.py +++ /dev/null @@ -1,964 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 ApiVersionSetOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 |
|-------------|-------------|-------------|-------------|
. 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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/_api_wiki_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wiki_operations.py deleted file mode 100644 index d8c2628388c5..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wiki_operations.py +++ /dev/null @@ -1,783 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_entity_tag_request( - resource_group_name: str, service_name: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default", - ) # 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])?$", - ), - "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 - _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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default", - ) # 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])?$", - ), - "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 - _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, - 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-05-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}/apis/{apiId}/wikis/default", - ) # 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])?$", - ), - "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 - _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, 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-05-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}/apis/{apiId}/wikis/default", - ) # 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])?$", - ), - "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 - _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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default", - ) # 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])?$", - ), - "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 - _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 ApiWikiOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_wiki` 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_entity_tag(self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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, api_id: str, **kwargs: Any) -> _models.WikiContract: - """Gets the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("WikiContract", 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, - api_id: str, - parameters: _models.WikiContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiContract - :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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - parameters: Union[_models.WikiContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: Create parameters. Is either a WikiContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiContract 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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = 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, "WikiContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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, 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("WikiContract", 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, - api_id: str, - if_match: str, - parameters: _models.WikiUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - 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: Wiki Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - 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: Wiki 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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - if_match: str, - parameters: Union[_models.WikiUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - 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: Wiki Update parameters. Is either a WikiUpdateContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract or IO[bytes] - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = 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, "WikiUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("WikiContract", 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, api_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. - 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 - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_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/_api_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wikis_operations.py deleted file mode 100644 index d874ff248474..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_wikis_operations.py +++ /dev/null @@ -1,219 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis", - ) # 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])?$", - ), - "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 ApiWikisOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`api_wikis` 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, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.WikiContract"]: - """Gets the wikis 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 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 | eq | contains |
. 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 WikiContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.WikiContract] - :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.WikiCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("WikiCollection", 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/_authorization_access_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_access_policy_operations.py deleted file mode 100644 index df52f38ed2a0..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_access_policy_operations.py +++ /dev/null @@ -1,771 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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_authorization_request( - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_id, - "str", - max_length=256, - min_length=1, - pattern=r"^[^*#&+:<>?]+$", - ), - "authorizationId": _SERIALIZER.url( - "authorization_id", authorization_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_request( - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies/{authorizationAccessPolicyId}", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_id, - "str", - max_length=256, - min_length=1, - pattern=r"^[^*#&+:<>?]+$", - ), - "authorizationId": _SERIALIZER.url( - "authorization_id", authorization_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "authorizationAccessPolicyId": _SERIALIZER.url( - "authorization_access_policy_id", - authorization_access_policy_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, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_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-05-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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies/{authorizationAccessPolicyId}", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_id, - "str", - max_length=256, - min_length=1, - pattern=r"^[^*#&+:<>?]+$", - ), - "authorizationId": _SERIALIZER.url( - "authorization_id", authorization_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "authorizationAccessPolicyId": _SERIALIZER.url( - "authorization_access_policy_id", - authorization_access_policy_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_delete_request( - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies/{authorizationAccessPolicyId}", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_id, - "str", - max_length=256, - min_length=1, - pattern=r"^[^*#&+:<>?]+$", - ), - "authorizationId": _SERIALIZER.url( - "authorization_id", authorization_id, "str", max_length=256, min_length=1, pattern=r"^[^*#&+:<>?]+$" - ), - "authorizationAccessPolicyId": _SERIALIZER.url( - "authorization_access_policy_id", - authorization_access_policy_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") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AuthorizationAccessPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`authorization_access_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_authorization( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.AuthorizationAccessPolicyContract"]: - """Lists a collection of authorization access policy defined within a authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_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 - :return: An iterator like instance of either AuthorizationAccessPolicyContract or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract] - :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.AuthorizationAccessPolicyCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_authorization_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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("AuthorizationAccessPolicyCollection", 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, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - **kwargs: Any - ) -> _models.AuthorizationAccessPolicyContract: - """Gets the details of the authorization access 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 authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_id: str - :return: AuthorizationAccessPolicyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationAccessPolicyContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_id, - authorization_access_policy_id=authorization_access_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")) - - deserialized = self._deserialize("AuthorizationAccessPolicyContract", 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, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - parameters: _models.AuthorizationAccessPolicyContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationAccessPolicyContract: - """Creates or updates Authorization Access Policy. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :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: AuthorizationAccessPolicyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationAccessPolicyContract: - """Creates or updates Authorization Access Policy. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_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: AuthorizationAccessPolicyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - parameters: Union[_models.AuthorizationAccessPolicyContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.AuthorizationAccessPolicyContract: - """Creates or updates Authorization Access Policy. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_id: str - :param parameters: Create parameters. Is either a AuthorizationAccessPolicyContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract 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: AuthorizationAccessPolicyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationAccessPolicyContract] = 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, "AuthorizationAccessPolicyContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_id, - authorization_access_policy_id=authorization_access_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("AuthorizationAccessPolicyContract", 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, - authorization_provider_id: str, - authorization_id: str, - authorization_access_policy_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Deletes specific access policy from the Authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param authorization_access_policy_id: Identifier of the authorization access policy. Required. - :type authorization_access_policy_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 = { - 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, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_id, - authorization_access_policy_id=authorization_access_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/_authorization_login_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_login_links_operations.py deleted file mode 100644 index 084feae5cc96..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_login_links_operations.py +++ /dev/null @@ -1,271 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_post_request( - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_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-05-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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/getLoginLinks", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_id, - "str", - max_length=256, - min_length=1, - pattern=r"^[^*#&+:<>?]+$", - ), - "authorizationId": _SERIALIZER.url( - "authorization_id", authorization_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 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) - - -class AuthorizationLoginLinksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`authorization_login_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") - - @overload - def post( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: _models.AuthorizationLoginRequestContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationLoginResponseContract: - """Gets authorization login links. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AuthorizationLoginResponseContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def post( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationLoginResponseContract: - """Gets authorization login links. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create 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: AuthorizationLoginResponseContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def post( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: Union[_models.AuthorizationLoginRequestContract, IO[bytes]], - **kwargs: Any - ) -> _models.AuthorizationLoginResponseContract: - """Gets authorization login links. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Is either a AuthorizationLoginRequestContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract or - IO[bytes] - :return: AuthorizationLoginResponseContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationLoginResponseContract] = 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, "AuthorizationLoginRequestContract") - - _request = build_post_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AuthorizationLoginResponseContract", 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/_authorization_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_operations.py deleted file mode 100644 index 39109f9f6961..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_operations.py +++ /dev/null @@ -1,927 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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_authorization_provider_request( # pylint: disable=name-too-long - resource_group_name: str, - service_name: str, - authorization_provider_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_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_request( - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_id, - "str", - max_length=256, - min_length=1, - pattern=r"^[^*#&+:<>?]+$", - ), - "authorizationId": _SERIALIZER.url( - "authorization_id", authorization_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, - authorization_provider_id: str, - authorization_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-05-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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_id, - "str", - max_length=256, - min_length=1, - pattern=r"^[^*#&+:<>?]+$", - ), - "authorizationId": _SERIALIZER.url( - "authorization_id", authorization_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_delete_request( - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_id, - "str", - max_length=256, - min_length=1, - pattern=r"^[^*#&+:<>?]+$", - ), - "authorizationId": _SERIALIZER.url( - "authorization_id", authorization_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") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_confirm_consent_code_request( - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_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-05-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}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/confirmConsentCode", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_id, - "str", - max_length=256, - min_length=1, - pattern=r"^[^*#&+:<>?]+$", - ), - "authorizationId": _SERIALIZER.url( - "authorization_id", authorization_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 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) - - -class AuthorizationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`authorization` 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_authorization_provider( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.AuthorizationContract"]: - """Lists a collection of authorization providers defined within a authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_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 - :return: An iterator like instance of either AuthorizationContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationContract] - :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.AuthorizationCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_authorization_provider_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_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("AuthorizationCollection", 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, - authorization_provider_id: str, - authorization_id: str, - **kwargs: Any - ) -> _models.AuthorizationContract: - """Gets the details of the authorization 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 authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :return: AuthorizationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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("AuthorizationContract", 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, - authorization_provider_id: str, - authorization_id: str, - parameters: _models.AuthorizationContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationContract: - """Creates or updates authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract - :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: AuthorizationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationContract: - """Creates or updates authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_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: AuthorizationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: Union[_models.AuthorizationContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.AuthorizationContract: - """Creates or updates authorization. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Is either a AuthorizationContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract 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: AuthorizationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationContract] = 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, "AuthorizationContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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("AuthorizationContract", 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, - authorization_provider_id: str, - authorization_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Deletes specific Authorization from the Authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_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 = { - 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, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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 - - @overload - def confirm_consent_code( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: _models.AuthorizationConfirmConsentCodeRequestContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Confirm valid consent code to suppress Authorizations anti-phishing page. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Required. - :type parameters: - ~azure.mgmt.apimanagement.models.AuthorizationConfirmConsentCodeRequestContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def confirm_consent_code( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Confirm valid consent code to suppress Authorizations anti-phishing page. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def confirm_consent_code( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - authorization_id: str, - parameters: Union[_models.AuthorizationConfirmConsentCodeRequestContract, IO[bytes]], - **kwargs: Any - ) -> None: - """Confirm valid consent code to suppress Authorizations anti-phishing page. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param authorization_id: Identifier of the authorization. Required. - :type authorization_id: str - :param parameters: Create parameters. Is either a - AuthorizationConfirmConsentCodeRequestContract type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.apimanagement.models.AuthorizationConfirmConsentCodeRequestContract or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "AuthorizationConfirmConsentCodeRequestContract") - - _request = build_confirm_consent_code_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_id, - authorization_id=authorization_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - if cls: - return cls(pipeline_response, None, response_headers) # type: ignore 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 deleted file mode 100644 index 1d2cf54911b2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_provider_operations.py +++ /dev/null @@ -1,661 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders", - ) # 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_request( - resource_group_name: str, service_name: str, authorization_provider_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_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, - authorization_provider_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-05-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}/authorizationProviders/{authorizationProviderId}", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_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_delete_request( - resource_group_name: str, - service_name: str, - authorization_provider_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}", - ) # 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])?$", - ), - "authorizationProviderId": _SERIALIZER.url( - "authorization_provider_id", - authorization_provider_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") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class AuthorizationProviderOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`authorization_provider` 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.AuthorizationProviderContract"]: - """Lists a collection of authorization providers 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 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 - :return: An iterator like instance of either AuthorizationProviderContract or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationProviderContract] - :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.AuthorizationProviderCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("AuthorizationProviderCollection", 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, authorization_provider_id: str, **kwargs: Any - ) -> _models.AuthorizationProviderContract: - """Gets the details of the authorization provider 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 authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :return: AuthorizationProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationProviderContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_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("AuthorizationProviderContract", 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, - authorization_provider_id: str, - parameters: _models.AuthorizationProviderContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationProviderContract: - """Creates or updates authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :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: AuthorizationProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationProviderContract: - """Creates or updates authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_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: AuthorizationProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - authorization_provider_id: str, - parameters: Union[_models.AuthorizationProviderContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.AuthorizationProviderContract: - """Creates or updates authorization provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_id: str - :param parameters: Create parameters. Is either a AuthorizationProviderContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract 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: AuthorizationProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationProviderContract] = 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, "AuthorizationProviderContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authorization_provider_id=authorization_provider_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("AuthorizationProviderContract", 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, authorization_provider_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific authorization provider from 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 authorization_provider_id: Identifier of the authorization provider. Required. - :type authorization_provider_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 = { - 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, - authorization_provider_id=authorization_provider_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/_authorization_server_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py deleted file mode 100644 index 3b1a63e19c7e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py +++ /dev/null @@ -1,1043 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers", - ) # 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, authsid: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", - ) # 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])?$", - ), - "authsid": _SERIALIZER.url("authsid", authsid, "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, authsid: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", - ) # 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])?$", - ), - "authsid": _SERIALIZER.url("authsid", authsid, "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, - authsid: 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-05-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}/authorizationServers/{authsid}", - ) # 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])?$", - ), - "authsid": _SERIALIZER.url("authsid", authsid, "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, authsid: 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-05-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}/authorizationServers/{authsid}", - ) # 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])?$", - ), - "authsid": _SERIALIZER.url("authsid", authsid, "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, authsid: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}", - ) # 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])?$", - ), - "authsid": _SERIALIZER.url("authsid", authsid, "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_list_secrets_request( - resource_group_name: str, service_name: str, authsid: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/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])?$", - ), - "authsid": _SERIALIZER.url("authsid", authsid, "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 AuthorizationServerOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`authorization_server` 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.AuthorizationServerContract"]: - """Lists a collection of authorization servers 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 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 - :return: An iterator like instance of either AuthorizationServerContract or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerContract] - :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.AuthorizationServerCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("AuthorizationServerCollection", 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, authsid: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the authorizationServer 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 authsid: Identifier of the authorization server. Required. - :type authsid: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - authsid=authsid, - 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, authsid: str, **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Gets the details of the authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: str - :return: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationServerContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - authsid=authsid, - 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("AuthorizationServerContract", 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, - authsid: str, - parameters: _models.AuthorizationServerContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Creates new authorization server or updates an existing authorization server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authsid: Identifier of the authorization server. Required. - :type authsid: str - :param parameters: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :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: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - authsid: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Creates new authorization server or updates an existing authorization server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authsid: Identifier of the authorization server. Required. - :type authsid: 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: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - authsid: str, - parameters: Union[_models.AuthorizationServerContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Creates new authorization server or updates an existing authorization server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authsid: Identifier of the authorization server. Required. - :type authsid: str - :param parameters: Create or update parameters. Is either a AuthorizationServerContract type or - a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract 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: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationServerContract] = 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, "AuthorizationServerContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authsid=authsid, - 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("AuthorizationServerContract", 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, - authsid: str, - if_match: str, - parameters: _models.AuthorizationServerUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: 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: OAuth2 Server settings Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - authsid: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: 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: OAuth2 Server settings 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: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - authsid: str, - if_match: str, - parameters: Union[_models.AuthorizationServerUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.AuthorizationServerContract: - """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: 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: OAuth2 Server settings Update parameters. Is either a - AuthorizationServerUpdateContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract or - IO[bytes] - :return: AuthorizationServerContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationServerContract] = 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, "AuthorizationServerUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - authsid=authsid, - 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("AuthorizationServerContract", 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, authsid: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific authorization server 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 authsid: Identifier of the authorization server. Required. - :type authsid: 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 = { - 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, - authsid=authsid, - 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_secrets( - self, resource_group_name: str, service_name: str, authsid: str, **kwargs: Any - ) -> _models.AuthorizationServerSecretsContract: - """Gets the client secret details of the authorization server. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param authsid: Identifier of the authorization server. Required. - :type authsid: str - :return: AuthorizationServerSecretsContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AuthorizationServerSecretsContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_request( - resource_group_name=resource_group_name, - service_name=service_name, - authsid=authsid, - 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("AuthorizationServerSecretsContract", 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/_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py deleted file mode 100644 index 6449985133ac..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_backend_operations.py +++ /dev/null @@ -1,1135 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, 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-05-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}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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) - - -def build_reconnect_request( - resource_group_name: str, service_name: 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-05-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}/backends/{backendId}/reconnect", - ) # 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])?$", - ), - "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 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) - - -class BackendOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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_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.BackendContract"]: - """Lists a collection of backends in the specified 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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 - - @overload - def reconnect( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - parameters: Optional[_models.BackendReconnectContract] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Notifies the API Management gateway to create a new connection to the backend after the - specified timeout. If no timeout was specified, timeout of 2 minutes is used. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: 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: Reconnect request parameters. Default value is None. - :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def reconnect( - self, - resource_group_name: str, - service_name: str, - backend_id: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Notifies the API Management gateway to create a new connection to the backend after the - specified timeout. If no timeout was specified, timeout of 2 minutes is used. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: 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: Reconnect request parameters. 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def reconnect( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - backend_id: str, - parameters: Optional[Union[_models.BackendReconnectContract, IO[bytes]]] = None, - **kwargs: Any - ) -> None: - """Notifies the API Management gateway to create a new connection to the backend after the - specified timeout. If no timeout was specified, timeout of 2 minutes is used. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: 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: Reconnect request parameters. Is either a BackendReconnectContract type or a - IO[bytes] type. Default value is None. - :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "BackendReconnectContract") - else: - _json = None - - _request = build_reconnect_request( - resource_group_name=resource_group_name, - service_name=service_name, - backend_id=backend_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 [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) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore 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 deleted file mode 100644 index 036c421cc1cd..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_cache_operations.py +++ /dev/null @@ -1,939 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - *, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches", - ) # 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 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, cache_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}", - ) # 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])?$", - ), - "cacheId": _SERIALIZER.url("cache_id", cache_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, cache_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}", - ) # 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])?$", - ), - "cacheId": _SERIALIZER.url("cache_id", cache_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, - cache_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-05-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}/caches/{cacheId}", - ) # 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])?$", - ), - "cacheId": _SERIALIZER.url("cache_id", cache_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, cache_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-05-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}/caches/{cacheId}", - ) # 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])?$", - ), - "cacheId": _SERIALIZER.url("cache_id", cache_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, cache_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}", - ) # 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])?$", - ), - "cacheId": _SERIALIZER.url("cache_id", cache_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 CacheOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`cache` 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, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.CacheContract"]: - """Lists a collection of all external Caches in the specified 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 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 CacheContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.CacheContract] - :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.CacheCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("CacheCollection", 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, cache_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - cache_id=cache_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, cache_id: str, **kwargs: Any) -> _models.CacheContract: - """Gets the details of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_id: str - :return: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.CacheContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - cache_id=cache_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("CacheContract", 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, - cache_id: str, - parameters: _models.CacheContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CacheContract: - """Creates or updates an External Cache to be used in Api Management instance. - - .. seealso:: - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-cache-external - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_id: str - :param parameters: Create or Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.CacheContract - :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: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CacheContract: - """Creates or updates an External Cache to be used in Api Management instance. - - .. seealso:: - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-cache-external - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - parameters: Union[_models.CacheContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.CacheContract: - """Creates or updates an External Cache to be used in Api Management instance. - - .. seealso:: - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-cache-external - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_id: str - :param parameters: Create or Update parameters. Is either a CacheContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.CacheContract 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: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.CacheContract] = 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, "CacheContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - cache_id=cache_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("CacheContract", 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, - cache_id: str, - if_match: str, - parameters: _models.CacheUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CacheContract: - """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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.CacheUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CacheContract: - """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - cache_id: str, - if_match: str, - parameters: Union[_models.CacheUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.CacheContract: - """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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 CacheUpdateParameters type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters or IO[bytes] - :return: CacheContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.CacheContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.CacheContract] = 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, "CacheUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - cache_id=cache_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("CacheContract", 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, cache_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific Cache. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' - or valid Azure region identifier). Required. - :type cache_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 = { - 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, - cache_id=cache_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/_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py deleted file mode 100644 index 1efcf08852ac..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_certificate_operations.py +++ /dev/null @@ -1,888 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 CertificateOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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_service( - self, - resource_group_name: str, - service_name: 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 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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/_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py deleted file mode 100644 index 9c64277f242b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_item_operations.py +++ /dev/null @@ -1,754 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, content_type_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems", - ) # 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])?$", - ), - "contentTypeId": _SERIALIZER.url("content_type_id", content_type_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, - content_type_id: str, - content_item_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}", - ) # 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])?$", - ), - "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"), - } - - _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, - content_type_id: str, - content_item_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}", - ) # 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])?$", - ), - "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"), - } - - _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, - content_type_id: str, - content_item_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-05-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}/contentTypes/{contentTypeId}/contentItems/{contentItemId}", - ) # 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])?$", - ), - "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"), - } - - _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, - content_type_id: str, - content_item_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}", - ) # 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])?$", - ), - "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"), - } - - _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 ContentItemOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`content_item` 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, content_type_id: str, **kwargs: Any - ) -> Iterable["_models.ContentItemContract"]: - """Lists developer portal's content items specified by the provided content type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :return: An iterator like instance of either ContentItemContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentItemContract] - :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.ContentItemCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - content_type_id=content_type_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("ContentItemCollection", 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, content_type_id: str, content_item_id: str, **kwargs: Any - ) -> bool: - """Returns the entity state (ETag) version of the developer portal's content item 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 content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - content_type_id=content_type_id, - content_item_id=content_item_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, content_type_id: str, content_item_id: str, **kwargs: Any - ) -> _models.ContentItemContract: - """Returns the developer portal's content item 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 content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_id: str - :return: ContentItemContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ContentItemContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - content_type_id=content_type_id, - content_item_id=content_item_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("ContentItemContract", 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, - content_type_id: str, - content_item_id: str, - parameters: _models.ContentItemContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ContentItemContract: - """Creates a new developer portal's content item specified by the provided content type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_id: str - :param parameters: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ContentItemContract - :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: ContentItemContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - content_item_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ContentItemContract: - """Creates a new developer portal's content item specified by the provided content type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_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: ContentItemContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - content_item_id: str, - parameters: Union[_models.ContentItemContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.ContentItemContract: - """Creates a new developer portal's content item specified by the provided content type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_id: str - :param parameters: Create or update parameters. Is either a ContentItemContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ContentItemContract 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: ContentItemContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ContentItemContract] = 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, "ContentItemContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - content_type_id=content_type_id, - content_item_id=content_item_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("ContentItemContract", 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, - content_type_id: str, - content_item_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Removes the specified developer portal's content item. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param content_item_id: Content item identifier. Required. - :type content_item_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 = { - 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, - content_type_id=content_type_id, - content_item_id=content_item_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/_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py deleted file mode 100644 index 2f4da9635f7c..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py +++ /dev/null @@ -1,616 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes", - ) # 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) - - -def build_get_request( - resource_group_name: str, service_name: str, content_type_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}", - ) # 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])?$", - ), - "contentTypeId": _SERIALIZER.url("content_type_id", content_type_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, - content_type_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-05-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}/contentTypes/{contentTypeId}", - ) # 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])?$", - ), - "contentTypeId": _SERIALIZER.url("content_type_id", content_type_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, - content_type_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}", - ) # 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])?$", - ), - "contentTypeId": _SERIALIZER.url("content_type_id", content_type_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 ContentTypeOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`content_type` 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.ContentTypeContract"]: - """Lists the developer portal's content types. Content types describe content items' properties, - validation rules, and constraints. - - :param resource_group_name: The name of the resource group. The name 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 ContentTypeContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentTypeContract] - :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.ContentTypeCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("ContentTypeCollection", 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, content_type_id: str, **kwargs: Any - ) -> _models.ContentTypeContract: - """Gets the details of the developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :return: ContentTypeContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ContentTypeContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - content_type_id=content_type_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("ContentTypeContract", 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, - content_type_id: str, - parameters: _models.ContentTypeContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ContentTypeContract: - """Creates or updates the developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. Custom content types' identifiers need to start - with the ``c-`` prefix. Built-in content types can't be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param parameters: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract - :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: ContentTypeContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ContentTypeContract: - """Creates or updates the developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. Custom content types' identifiers need to start - with the ``c-`` prefix. Built-in content types can't be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_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: ContentTypeContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - content_type_id: str, - parameters: Union[_models.ContentTypeContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.ContentTypeContract: - """Creates or updates the developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. Custom content types' identifiers need to start - with the ``c-`` prefix. Built-in content types can't be modified. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_type_id: str - :param parameters: Create or update parameters. Is either a ContentTypeContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract 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: ContentTypeContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ContentTypeContract] = 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, "ContentTypeContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - content_type_id=content_type_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("ContentTypeContract", 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, content_type_id: str, if_match: str, **kwargs: Any - ) -> None: - """Removes the specified developer portal's content type. Content types describe content items' - properties, validation rules, and constraints. Built-in content types (with identifiers - starting with the ``c-`` prefix) can't be removed. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param content_type_id: Content type identifier. Required. - :type content_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 = { - 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, - content_type_id=content_type_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/_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py deleted file mode 100644 index 302aa8c989bf..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py +++ /dev/null @@ -1,721 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_entity_tag_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation", - ) # 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="HEAD", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation", - ) # 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) - - -def build_update_request( - resource_group_name: str, service_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-05-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}/portalsettings/delegation", - ) # 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["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_create_or_update_request( - resource_group_name: str, service_name: 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-05-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}/portalsettings/delegation", - ) # 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 - 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_list_secrets_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/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])?$", - ), - "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 DelegationSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`delegation_settings` 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_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the DelegationSettings. - - :param resource_group_name: The name of the resource group. The name 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: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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, **kwargs: Any) -> _models.PortalDelegationSettings: - """Get Delegation Settings for the Portal. - - :param resource_group_name: The name of the resource group. The name 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: PortalDelegationSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalDelegationSettings] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("PortalDelegationSettings", 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, - if_match: str, - parameters: _models.PortalDelegationSettings, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Delegation settings. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Delegation settings. 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: Union[_models.PortalDelegationSettings, IO[bytes]], - **kwargs: Any - ) -> None: - """Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Delegation settings. Is either a PortalDelegationSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "PortalDelegationSettings") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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 [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 create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: _models.PortalDelegationSettings, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalDelegationSettings: - """Create or Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :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: PortalDelegationSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalDelegationSettings: - """Create or Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is 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: 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: PortalDelegationSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.PortalDelegationSettings, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.PortalDelegationSettings: - """Create or Update Delegation settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is either a PortalDelegationSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings 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: PortalDelegationSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalDelegationSettings] = 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, "PortalDelegationSettings") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - deserialized = self._deserialize("PortalDelegationSettings", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_secrets( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.PortalSettingValidationKeyContract: - """Gets the secret validation key of the DelegationSettings. - - :param resource_group_name: The name of the resource group. The name 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: PortalSettingValidationKeyContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSettingValidationKeyContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_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) - - _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("PortalSettingValidationKeyContract", 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/_deleted_services_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py deleted file mode 100644 index d269e1857b77..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py +++ /dev/null @@ -1,407 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, Iterator, Optional, TypeVar, Union, cast -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 -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_subscription_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices" - ) - 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) - - -def build_get_by_name_request(service_name: str, location: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "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"), - "location": _SERIALIZER.url("location", location, "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_purge_request(service_name: str, location: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}", - ) # pylint: disable=line-too-long - path_format_arguments = { - "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"), - "location": _SERIALIZER.url("location", location, "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 DeletedServicesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`deleted_services` 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_subscription(self, **kwargs: Any) -> Iterable["_models.DeletedServiceContract"]: - """Lists all soft-deleted services available for undelete for the given subscription. - - :return: An iterator like instance of either DeletedServiceContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DeletedServiceContract] - :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.DeletedServicesCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_subscription_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("DeletedServicesCollection", 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_by_name(self, service_name: str, location: str, **kwargs: Any) -> _models.DeletedServiceContract: - """Get soft-deleted Api Management Service by name. - - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param location: The location of the deleted API Management service. Required. - :type location: str - :return: DeletedServiceContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.DeletedServiceContract] = kwargs.pop("cls", None) - - _request = build_get_by_name_request( - service_name=service_name, - location=location, - 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("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) -> Iterator[bytes]: - error_map: MutableMapping = { - 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_purge_request( - service_name=service_name, - location=location, - 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, 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_purge(self, service_name: str, location: str, **kwargs: Any) -> LROPoller[_models.DeletedServiceContract]: - """Purges Api Management Service (deletes it with no option to undelete). - - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param location: The location of the deleted API Management service. Required. - :type location: str - :return: An instance of LROPoller that returns either DeletedServiceContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] - :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._purge_initial( - service_name=service_name, - location=location, - 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("DeletedServiceContract", 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.DeletedServiceContract].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.DeletedServiceContract]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 7feed40782f4..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_diagnostic_operations.py +++ /dev/null @@ -1,964 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 DiagnosticOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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_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.DiagnosticContract"]: - """Lists all diagnostics 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - diagnostic_id: str, - if_match: str, - parameters: _models.DiagnosticContract, - *, - 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 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.DiagnosticContract - :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, - 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 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, - diagnostic_id: str, - if_match: str, - parameters: Union[_models.DiagnosticContract, 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 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 DiagnosticContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract 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 = { - 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_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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, 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 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 = { - 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, - 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/_documentation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_documentation_operations.py deleted file mode 100644 index 398a5998a3c0..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_documentation_operations.py +++ /dev/null @@ -1,964 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations", - ) # 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, documentation_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}", - ) # 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])?$", - ), - "documentationId": _SERIALIZER.url( - "documentation_id", documentation_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, documentation_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}", - ) # 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])?$", - ), - "documentationId": _SERIALIZER.url( - "documentation_id", documentation_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, - documentation_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-05-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}/documentations/{documentationId}", - ) # 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])?$", - ), - "documentationId": _SERIALIZER.url( - "documentation_id", documentation_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, - documentation_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-05-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}/documentations/{documentationId}", - ) # 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])?$", - ), - "documentationId": _SERIALIZER.url( - "documentation_id", documentation_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, - documentation_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}", - ) # 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])?$", - ), - "documentationId": _SERIALIZER.url( - "documentation_id", documentation_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") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -class DocumentationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`documentation` 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.DocumentationContract"]: - """Lists all Documentations 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | eq | contains |
. 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 DocumentationContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DocumentationContract] - :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.DocumentationCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("DocumentationCollection", 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, documentation_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - documentation_id=documentation_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, documentation_id: str, **kwargs: Any - ) -> _models.DocumentationContract: - """Gets the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_id: str - :return: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.DocumentationContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - documentation_id=documentation_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("DocumentationContract", 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, - documentation_id: str, - parameters: _models.DocumentationContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DocumentationContract: - """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DocumentationContract - :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: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - documentation_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DocumentationContract: - """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - documentation_id: str, - parameters: Union[_models.DocumentationContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.DocumentationContract: - """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_id: str - :param parameters: Create parameters. Is either a DocumentationContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DocumentationContract 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: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.DocumentationContract] = 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, "DocumentationContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - documentation_id=documentation_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("DocumentationContract", 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, - documentation_id: str, - if_match: str, - parameters: _models.DocumentationUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DocumentationContract: - """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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: Documentation Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DocumentationUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - documentation_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.DocumentationContract: - """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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: Documentation 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: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - documentation_id: str, - if_match: str, - parameters: Union[_models.DocumentationUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.DocumentationContract: - """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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: Documentation Update parameters. Is either a DocumentationUpdateContract - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DocumentationUpdateContract or IO[bytes] - :return: DocumentationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.DocumentationContract] = 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, "DocumentationUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - documentation_id=documentation_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("DocumentationContract", 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, documentation_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management - service instance. Required. - :type documentation_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 = { - 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, - documentation_id=documentation_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/_email_template_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py deleted file mode 100644 index 4e0ccfd883ca..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_email_template_operations.py +++ /dev/null @@ -1,1030 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates", - ) # 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, - template_name: Union[str, _models.TemplateName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}", - ) # 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])?$", - ), - "templateName": _SERIALIZER.url("template_name", template_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="HEAD", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}", - ) # 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])?$", - ), - "templateName": _SERIALIZER.url("template_name", template_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, - template_name: Union[str, _models.TemplateName], - 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-05-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}/templates/{templateName}", - ) # 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])?$", - ), - "templateName": _SERIALIZER.url("template_name", template_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") - 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, - template_name: Union[str, _models.TemplateName], - 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-05-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}/templates/{templateName}", - ) # 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])?$", - ), - "templateName": _SERIALIZER.url("template_name", template_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["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, - template_name: Union[str, _models.TemplateName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}", - ) # 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])?$", - ), - "templateName": _SERIALIZER.url("template_name", template_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["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 EmailTemplateOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`email_template` 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.EmailTemplateContract"]: - """Gets all email templates. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| 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 EmailTemplateContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateContract] - :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.EmailTemplateCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("EmailTemplateCollection", 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, - template_name: Union[str, _models.TemplateName], - **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the email template 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 template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - template_name=template_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) - - 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, - template_name: Union[str, _models.TemplateName], - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Gets the details of the email template 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 template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :return: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.EmailTemplateContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - template_name=template_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("EmailTemplateContract", 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, - template_name: Union[str, _models.TemplateName], - parameters: _models.EmailTemplateUpdateParameters, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates an Email Template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :param parameters: Email Template update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters - :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: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates an Email Template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :param parameters: Email Template 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: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - parameters: Union[_models.EmailTemplateUpdateParameters, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates an Email Template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :param parameters: Email Template update parameters. Is either a EmailTemplateUpdateParameters - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters 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: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.EmailTemplateContract] = 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, "EmailTemplateUpdateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - template_name=template_name, - 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) - - deserialized = self._deserialize("EmailTemplateContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - if_match: str, - parameters: _models.EmailTemplateUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates API Management email template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :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.EmailTemplateUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates API Management email template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :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: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - template_name: Union[str, _models.TemplateName], - if_match: str, - parameters: Union[_models.EmailTemplateUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.EmailTemplateContract: - """Updates API Management email template. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :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 EmailTemplateUpdateParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or IO[bytes] - :return: EmailTemplateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.EmailTemplateContract] = 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, "EmailTemplateUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - template_name=template_name, - 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("EmailTemplateContract", 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, - template_name: Union[str, _models.TemplateName], - if_match: str, - **kwargs: Any - ) -> None: - """Reset the Email Template to default template provided by 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 template_name: Email Template Name Identifier. Known values are: - "applicationApprovedNotificationMessage", "accountClosedDeveloper", - "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", - "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", - "confirmSignUpIdentityDefault", "newIssueNotificationMessage", - "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", - "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and - "requestDeveloperNotificationMessage". Required. - :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName - :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 = { - 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, - template_name=template_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, 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/_gateway_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py deleted file mode 100644 index 71c5d2039e7e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_api_operations.py +++ /dev/null @@ -1,638 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - gateway_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-05-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}/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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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, gateway_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-05-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}/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])?$", - ), - "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"), - } - - _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, gateway_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-05-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}/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])?$", - ), - "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"), - } - - _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, gateway_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-05-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}/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])?$", - ), - "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"), - } - - _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 GatewayApiOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`gateway_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, - gateway_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ApiContract"]: - """Lists a collection of the APIs associated with a 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 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 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 = { - 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, - gateway_id=gateway_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("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, gateway_id: str, api_id: str, **kwargs: Any - ) -> bool: - """Checks that API entity specified by identifier is associated with the Gateway 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 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - gateway_id=gateway_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 - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - parameters: Optional[_models.AssociationContract] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiContract: - """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: Default value is None. - :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract - :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 create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - parameters: Optional[IO[bytes]] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ApiContract: - """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: 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: ApiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ApiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - api_id: str, - parameters: Optional[Union[_models.AssociationContract, IO[bytes]]] = None, - **kwargs: Any - ) -> _models.ApiContract: - """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :param parameters: Is either a AssociationContract type or a IO[bytes] type. Default value is - None. - :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract 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 = { - 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: - if parameters is not None: - _json = self._serialize.body(parameters, "AssociationContract") - else: - _json = None - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_id, - api_id=api_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("ApiContract", 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, gateway_id: str, api_id: str, **kwargs: Any - ) -> None: - """Deletes the specified API from the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. - Required. - :type api_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - gateway_id=gateway_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, 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/_gateway_certificate_authority_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py deleted file mode 100644 index 00f713439649..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_certificate_authority_operations.py +++ /dev/null @@ -1,809 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - gateway_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-05-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}/certificateAuthorities", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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, - gateway_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-05-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}/certificateAuthorities/{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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "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, - gateway_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-05-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}/certificateAuthorities/{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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "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, - gateway_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-05-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}/certificateAuthorities/{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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "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, - gateway_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-05-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}/certificateAuthorities/{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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str", max_length=80, min_length=1), - "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) - - -class GatewayCertificateAuthorityOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`gateway_certificate_authority` 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, - gateway_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.GatewayCertificateAuthorityContract"]: - """Lists the collection of Certificate Authorities for the specified Gateway 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 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - 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 - :return: An iterator like instance of either GatewayCertificateAuthorityContract or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract] - :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.GatewayCertificateAuthorityCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - gateway_id=gateway_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("GatewayCertificateAuthorityCollection", 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, gateway_id: str, certificate_id: str, **kwargs: Any - ) -> bool: - """Checks if Certificate entity is assigned to Gateway entity as Certificate Authority. - - :param resource_group_name: The name of the resource group. The name is 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 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 = { - 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, - gateway_id=gateway_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, gateway_id: str, certificate_id: str, **kwargs: Any - ) -> _models.GatewayCertificateAuthorityContract: - """Get assigned Gateway Certificate Authority 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 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API - Management service instance. Required. - :type certificate_id: str - :return: GatewayCertificateAuthorityContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayCertificateAuthorityContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_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("GatewayCertificateAuthorityContract", 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, - gateway_id: str, - certificate_id: str, - parameters: _models.GatewayCertificateAuthorityContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayCertificateAuthorityContract: - """Assign Certificate entity to Gateway entity as Certificate Authority. - - :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API - Management service instance. Required. - :type certificate_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :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: GatewayCertificateAuthorityContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - certificate_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayCertificateAuthorityContract: - """Assign Certificate entity to Gateway entity as Certificate Authority. - - :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API - Management service instance. Required. - :type certificate_id: str - :param 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: GatewayCertificateAuthorityContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - certificate_id: str, - parameters: Union[_models.GatewayCertificateAuthorityContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.GatewayCertificateAuthorityContract: - """Assign Certificate entity to Gateway entity as Certificate Authority. - - :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API - Management service instance. Required. - :type certificate_id: str - :param parameters: Is either a GatewayCertificateAuthorityContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract 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: GatewayCertificateAuthorityContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayCertificateAuthorityContract] = 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, "GatewayCertificateAuthorityContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_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("GatewayCertificateAuthorityContract", 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, - gateway_id: str, - certificate_id: str, - if_match: str, - **kwargs: Any - ) -> None: - """Remove relationship between Certificate Authority and Gateway 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 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 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 = { - 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, - gateway_id=gateway_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 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 deleted file mode 100644 index 57d735d69491..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py +++ /dev/null @@ -1,788 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - gateway_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-05-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}/hostnameConfigurations", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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, gateway_id: str, hc_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-05-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}/hostnameConfigurations/{hcId}", - ) # 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])?$", - ), - "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"), - } - - _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, gateway_id: str, hc_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-05-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}/hostnameConfigurations/{hcId}", - ) # 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])?$", - ), - "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"), - } - - _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, - gateway_id: str, - hc_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-05-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}/hostnameConfigurations/{hcId}", - ) # 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])?$", - ), - "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"), - } - - _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, - gateway_id: str, - hc_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-05-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}/hostnameConfigurations/{hcId}", - ) # 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])?$", - ), - "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"), - } - - _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 GatewayHostnameConfigurationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`gateway_hostname_configuration` 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, - gateway_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.GatewayHostnameConfigurationContract"]: - """Lists the collection of hostname configurations for the specified 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| hostname - | 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 GatewayHostnameConfigurationContract or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] - :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.GatewayHostnameConfigurationCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - gateway_id=gateway_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("GatewayHostnameConfigurationCollection", 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, gateway_id: str, hc_id: str, **kwargs: Any - ) -> bool: - """Checks that hostname configuration entity specified by identifier exists for specified Gateway - 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 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - gateway_id=gateway_id, - hc_id=hc_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, gateway_id: str, hc_id: str, **kwargs: Any - ) -> _models.GatewayHostnameConfigurationContract: - """Get details of a hostname configuration. - - :param resource_group_name: The name of the resource group. The name is 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :return: GatewayHostnameConfigurationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayHostnameConfigurationContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_id, - hc_id=hc_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("GatewayHostnameConfigurationContract", 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, - gateway_id: str, - hc_id: str, - parameters: _models.GatewayHostnameConfigurationContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayHostnameConfigurationContract: - """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :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: GatewayHostnameConfigurationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - hc_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayHostnameConfigurationContract: - """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :param 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: GatewayHostnameConfigurationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - hc_id: str, - parameters: Union[_models.GatewayHostnameConfigurationContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.GatewayHostnameConfigurationContract: - """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_id: str - :param parameters: Is either a GatewayHostnameConfigurationContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract 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: GatewayHostnameConfigurationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayHostnameConfigurationContract] = 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, "GatewayHostnameConfigurationContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_id, - hc_id=hc_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("GatewayHostnameConfigurationContract", 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, gateway_id: str, hc_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified hostname configuration from the specified 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent - Gateway entity. Required. - :type hc_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 = { - 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, - gateway_id=gateway_id, - hc_id=hc_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/_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py deleted file mode 100644 index 380339b9f74e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_operations.py +++ /dev/null @@ -1,1897 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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 - ), - "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, 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-05-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}", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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, 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-05-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}", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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, - gateway_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-05-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}", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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, gateway_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-05-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}", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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, gateway_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-05-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}", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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) - - -def build_list_keys_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-05-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}/listKeys", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_regenerate_key_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-05-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}/regenerateKey", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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 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_generate_token_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-05-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}/generateToken", - ) # 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])?$", - ), - "gatewayId": _SERIALIZER.url("gateway_id", gateway_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 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-05-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-05-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-05-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 - - # 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) - - -class GatewayOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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") - - @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.GatewayContract"]: - """Lists a collection of gateways registered with 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| region | - 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 GatewayContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayContract] - :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.GatewayCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("GatewayCollection", 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, gateway_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the Gateway 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 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: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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 [200]: - map_error(status_code=response.status_code, 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, gateway_id: str, **kwargs: Any - ) -> _models.GatewayContract: - """Gets the details of the Gateway 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 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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayContract] = kwargs.pop("cls", None) - - _request = build_get_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 [200]: - map_error(status_code=response.status_code, 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("GatewayContract", 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, - gateway_id: str, - parameters: _models.GatewayContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayContract: - """Creates or updates a Gateway to be used in Api Management 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 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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract - :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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayContract: - """Creates or updates a Gateway to be used in Api Management 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 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: 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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: Union[_models.GatewayContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.GatewayContract: - """Creates or updates a Gateway to be used in Api Management 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 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: Is either a GatewayContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract 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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayContract] = 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, "GatewayContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_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("GatewayContract", 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, - gateway_id: str, - if_match: str, - parameters: _models.GatewayContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayContract: - """Updates the details of the gateway 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 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 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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayContract: - """Updates the details of the gateway 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 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 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: 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: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - if_match: str, - parameters: Union[_models.GatewayContract, IO[bytes]], - **kwargs: Any - ) -> _models.GatewayContract: - """Updates the details of the gateway 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 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 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: Is either a GatewayContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or IO[bytes] - :return: GatewayContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayContract] = 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, "GatewayContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - gateway_id=gateway_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("GatewayContract", 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, gateway_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific 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 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 = { - 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, - gateway_id=gateway_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_keys( - self, resource_group_name: str, service_name: str, gateway_id: str, **kwargs: Any - ) -> _models.GatewayKeysContract: - """Retrieves gateway 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 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: GatewayKeysContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayKeysContract] = kwargs.pop("cls", None) - - _request = build_list_keys_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 [200]: - map_error(status_code=response.status_code, 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("GatewayKeysContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def regenerate_key( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: _models.GatewayKeyRegenerationRequestContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Regenerates specified gateway key invalidating any tokens created with it. - - :param resource_group_name: The name of the resource group. The name is 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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def regenerate_key( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Regenerates specified gateway key invalidating any tokens created with it. - - :param resource_group_name: The name of the resource group. The name is 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: 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def regenerate_key( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: Union[_models.GatewayKeyRegenerationRequestContract, IO[bytes]], - **kwargs: Any - ) -> None: - """Regenerates specified gateway key invalidating any tokens created with it. - - :param resource_group_name: The name of the resource group. The name is 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: Is either a GatewayKeyRegenerationRequestContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract or - IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "GatewayKeyRegenerationRequestContract") - - _request = build_regenerate_key_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 [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 generate_token( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: _models.GatewayTokenRequestContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayTokenContract: - """Gets the Shared Access Authorization Token for the 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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: GatewayTokenContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def generate_token( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.GatewayTokenContract: - """Gets the Shared Access Authorization Token for the 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: 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: GatewayTokenContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def generate_token( - self, - resource_group_name: str, - service_name: str, - gateway_id: str, - parameters: Union[_models.GatewayTokenRequestContract, IO[bytes]], - **kwargs: Any - ) -> _models.GatewayTokenContract: - """Gets the Shared Access Authorization Token for the 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: Is either a GatewayTokenRequestContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract or IO[bytes] - :return: GatewayTokenContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GatewayTokenContract] = 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, "GatewayTokenRequestContract") - - _request = build_generate_token_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("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 = { - 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 = { - 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 = { - 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 - - return 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 deleted file mode 100644 index 46f873f8efe9..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_global_schema_operations.py +++ /dev/null @@ -1,822 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 GlobalSchemaOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.GlobalSchemaContract"]: - """Lists a collection of schemas registered with 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - schema_id: str, - parameters: Union[_models.GlobalSchemaContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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 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, - 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 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 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, - 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 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 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, - 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, 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 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 = { - 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, - 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/_graph_ql_api_resolver_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_operations.py deleted file mode 100644 index c67287da1396..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_operations.py +++ /dev/null @@ -1,1013 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers", - ) # 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])?$", - ), - "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, api_id: str, resolver_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}", - ) # 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])?$", - ), - "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"), - } - - _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, api_id: str, resolver_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}", - ) # 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])?$", - ), - "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"), - } - - _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, - api_id: str, - resolver_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-05-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}/apis/{apiId}/resolvers/{resolverId}", - ) # 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])?$", - ), - "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"), - } - - _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, - api_id: str, - resolver_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-05-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}/apis/{apiId}/resolvers/{resolverId}", - ) # 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])?$", - ), - "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"), - } - - _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, - api_id: str, - resolver_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}", - ) # 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])?$", - ), - "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"), - } - - _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 GraphQLApiResolverOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`graph_ql_api_resolver` 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, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ResolverContract"]: - """Lists a collection of the resolvers for the specified GraphQL 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 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 - |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| path | 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 ResolverContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ResolverContract] - :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.ResolverCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("ResolverCollection", 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, api_id: str, resolver_id: str, **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the GraphQL API resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - api_id=api_id, - resolver_id=resolver_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, api_id: str, resolver_id: str, **kwargs: Any - ) -> _models.ResolverContract: - """Gets the details of the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_id: str - :return: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ResolverContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - resolver_id=resolver_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("ResolverContract", 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, - api_id: str, - resolver_id: str, - parameters: _models.ResolverContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResolverContract: - """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ResolverContract - :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: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - resolver_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResolverContract: - """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - resolver_id: str, - parameters: Union[_models.ResolverContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.ResolverContract: - """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_id: str - :param parameters: Create parameters. Is either a ResolverContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.ResolverContract 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: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ResolverContract] = 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, "ResolverContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - resolver_id=resolver_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("ResolverContract", 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, - api_id: str, - resolver_id: str, - if_match: str, - parameters: _models.ResolverUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResolverContract: - """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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: GraphQL API Resolver Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ResolverUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - resolver_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.ResolverContract: - """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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: GraphQL API Resolver 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: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - api_id: str, - resolver_id: str, - if_match: str, - parameters: Union[_models.ResolverUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.ResolverContract: - """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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: GraphQL API Resolver Update parameters. Is either a ResolverUpdateContract - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.ResolverUpdateContract or IO[bytes] - :return: ResolverContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ResolverContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ResolverContract] = 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, "ResolverUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - resolver_id=resolver_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("ResolverContract", 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, api_id: str, resolver_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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/_graph_ql_api_resolver_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_policy_operations.py deleted file mode 100644 index 99f13ada4457..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_graph_ql_api_resolver_policy_operations.py +++ /dev/null @@ -1,821 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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_resolver_request( - resource_group_name: str, service_name: str, api_id: str, resolver_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/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])?$", - ), - "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"), - } - - _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, - api_id: str, - resolver_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/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])?$", - ), - "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"), - } - - _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, - api_id: str, - resolver_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/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])?$", - ), - "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"), - } - - _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, - api_id: str, - resolver_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-05-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}/apis/{apiId}/resolvers/{resolverId}/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])?$", - ), - "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"), - } - - _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, - api_id: str, - resolver_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/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])?$", - ), - "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"), - } - - _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 GraphQLApiResolverPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`graph_ql_api_resolver_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_resolver( - self, resource_group_name: str, service_name: str, api_id: str, resolver_id: str, **kwargs: Any - ) -> Iterable["_models.PolicyContract"]: - """Get the list of policy configuration at the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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_resolver_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - resolver_id=resolver_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, - api_id: str, - resolver_id: str, - policy_id: Union[str, _models.PolicyIdName], - **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the GraphQL API resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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, - api_id: str, - resolver_id: str, - policy_id: Union[str, _models.PolicyIdName], - format: Union[str, _models.PolicyExportFormat] = "xml", - **kwargs: Any - ) -> _models.PolicyContract: - """Get the policy configuration at the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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, - api_id: str, - resolver_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 GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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, - api_id: str, - resolver_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 GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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, - api_id: str, - resolver_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 GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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, - api_id: str, - resolver_id: str, - policy_id: Union[str, _models.PolicyIdName], - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the policy configuration at the GraphQL Api Resolver. - - :param resource_group_name: The name of the resource group. The name is 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API - Management service instance. Required. - :type resolver_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 = { - 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, - api_id=api_id, - resolver_id=resolver_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/_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py deleted file mode 100644 index a7fddfd8e765..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py +++ /dev/null @@ -1,945 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, 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-05-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}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 GroupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, group_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific group 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 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 = { - 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, - 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/_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py deleted file mode 100644 index ad7d179b3f84..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_user_operations.py +++ /dev/null @@ -1,541 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 GroupUserOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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/_identity_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py deleted file mode 100644 index 79eecb947139..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_identity_provider_operations.py +++ /dev/null @@ -1,1068 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders", - ) # 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) - - -def build_get_entity_tag_request( - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", - ) # 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])?$", - ), - "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_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="HEAD", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_request( - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", - ) # 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])?$", - ), - "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_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, - identity_provider_name: Union[str, _models.IdentityProviderType], - 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-05-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}/identityProviders/{identityProviderName}", - ) # 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])?$", - ), - "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_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") - 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - 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-05-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}/identityProviders/{identityProviderName}", - ) # 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])?$", - ), - "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_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["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, - identity_provider_name: Union[str, _models.IdentityProviderType], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}", - ) # 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])?$", - ), - "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_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["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_secrets_request( - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/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])?$", - ), - "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class IdentityProviderOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`identity_provider` 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.IdentityProviderContract"]: - """Lists a collection of Identity Provider configured in the specified service instance. - - .. seealso:: - - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-aad#how-to-authorize-developer-accounts-using-azure-active-directory - - :param resource_group_name: The name of the resource group. The name 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 IdentityProviderContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderContract] - :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.IdentityProviderList] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("IdentityProviderList", 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the identityProvider 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 identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - identity_provider_name=identity_provider_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) - - 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Gets the configuration details of the identity Provider configured in specified 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 identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :return: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IdentityProviderContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - identity_provider_name=identity_provider_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("IdentityProviderContract", 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - parameters: _models.IdentityProviderCreateContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Creates or Updates the IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract - :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: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Creates or Updates the IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - parameters: Union[_models.IdentityProviderCreateContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Creates or Updates the IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param parameters: Create parameters. Is either a IdentityProviderCreateContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract 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: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IdentityProviderContract] = 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, "IdentityProviderCreateContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - identity_provider_name=identity_provider_name, - 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("IdentityProviderContract", 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - if_match: str, - parameters: _models.IdentityProviderUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Updates an existing IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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.IdentityProviderUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Updates an existing IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - identity_provider_name: Union[str, _models.IdentityProviderType], - if_match: str, - parameters: Union[_models.IdentityProviderUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.IdentityProviderContract: - """Updates an existing IdentityProvider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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 IdentityProviderUpdateParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters or - IO[bytes] - :return: IdentityProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IdentityProviderContract] = 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, "IdentityProviderUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - identity_provider_name=identity_provider_name, - 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("IdentityProviderContract", 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the specified identity provider configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :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 = { - 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, - identity_provider_name=identity_provider_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, 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, - identity_provider_name: Union[str, _models.IdentityProviderType], - **kwargs: Any - ) -> _models.ClientSecretContract: - """Gets the client secret details of the Identity Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", - "google", "microsoft", "twitter", "aad", and "aadB2C". Required. - :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :return: ClientSecretContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ClientSecretContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_request( - resource_group_name=resource_group_name, - service_name=service_name, - identity_provider_name=identity_provider_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("ClientSecretContract", 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/_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py deleted file mode 100644 index 7d1d6dd03d2d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_issue_operations.py +++ /dev/null @@ -1,323 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues", - ) # 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_request( - resource_group_name: str, service_name: str, issue_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}", - ) # 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])?$", - ), - "issueId": _SERIALIZER.url( - "issue_id", issue_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) - - -class IssueOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`issue` 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.IssueContract"]: - """Lists a collection of issues in the specified 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| apiId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| - description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| state | 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 IssueContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueContract] - :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.IssueCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("IssueCollection", 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, issue_id: str, **kwargs: Any) -> _models.IssueContract: - """Gets API Management issue 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 issue_id: Issue identifier. Must be unique in the current API Management service - instance. Required. - :type issue_id: str - :return: IssueContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.IssueContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.IssueContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - issue_id=issue_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("IssueContract", 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/_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py deleted file mode 100644 index a214da520a00..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_logger_operations.py +++ /dev/null @@ -1,945 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, 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-05-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}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 LoggerOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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_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.LoggerContract"]: - """Lists a collection of loggers in the specified service instance. - - .. 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 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 = { - 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("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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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/_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py deleted file mode 100644 index eb409a00b08a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_named_value_operations.py +++ /dev/null @@ -1,1414 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 NamedValueOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - is_key_vault_refresh_failed: Optional[bool] = None, - **kwargs: Any - ) -> Iterable["_models.NamedValueContract"]: - """Lists a collection of named values defined within 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 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: When set to true, the response contains only named value - entities which failed refresh. Default value is None. - :type is_key_vault_refresh_failed: bool - :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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - named_value_id: str, - parameters: Union[_models.NamedValueCreateContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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, - 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 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, - 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 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, - 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, - named_value_id: str, - if_match: str, - parameters: Union[_models.NamedValueUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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, - 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 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, - 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 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, - 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, named_value_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific named value from 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, named_value_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - 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, 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 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, - 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/_network_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py deleted file mode 100644 index a72b56f7042a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_network_status_operations.py +++ /dev/null @@ -1,261 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, List, Optional, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/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"), - "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_list_by_location_request( - resource_group_name: str, service_name: str, location_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/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"), - "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])?$", - ), - "locationName": _SERIALIZER.url("location_name", location_name, "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 NetworkStatusOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`network_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 list_by_service( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> List[_models.NetworkStatusContractByLocation]: - """Gets the Connectivity Status to the external resources on which the Api Management service - depends from inside the Cloud Service. This also returns the DNS Servers as visible to the - CloudService. - - :param resource_group_name: The name of the resource group. The name 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: list of NetworkStatusContractByLocation or the result of cls(response) - :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[List[_models.NetworkStatusContractByLocation]] = 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.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("[NetworkStatusContractByLocation]", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_by_location( - self, resource_group_name: str, service_name: str, location_name: str, **kwargs: Any - ) -> _models.NetworkStatusContract: - """Gets the Connectivity Status to the external resources on which the Api Management service - depends from inside the Cloud Service. This also returns the DNS Servers as visible to the - CloudService. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param location_name: Location in which the API Management service is deployed. This is one of - the Azure Regions like West US, East US, South Central US. Required. - :type location_name: str - :return: NetworkStatusContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.NetworkStatusContract] = kwargs.pop("cls", None) - - _request = build_list_by_location_request( - resource_group_name=resource_group_name, - service_name=service_name, - location_name=location_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("NetworkStatusContract", 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/_notification_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py deleted file mode 100644 index 757a6e48a5e1..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_operations.py +++ /dev/null @@ -1,439 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - *, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 NotificationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - notification_name: Union[str, _models.NotificationName], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.NotificationContract: - """Create or Update API Management publisher 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 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 = { - 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, - 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/_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py deleted file mode 100644 index 15120d76b86b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_email_operations.py +++ /dev/null @@ -1,519 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 NotificationRecipientEmailOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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/_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py deleted file mode 100644 index 2fa7b7adf011..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_notification_recipient_user_operations.py +++ /dev/null @@ -1,522 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 NotificationRecipientUserOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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/_open_id_connect_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py deleted file mode 100644 index 98907791365a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_open_id_connect_provider_operations.py +++ /dev/null @@ -1,1043 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders", - ) # 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, opid: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", - ) # 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])?$", - ), - "opid": _SERIALIZER.url("opid", opid, "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, opid: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", - ) # 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])?$", - ), - "opid": _SERIALIZER.url("opid", opid, "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, - opid: 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-05-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}/openidConnectProviders/{opid}", - ) # 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])?$", - ), - "opid": _SERIALIZER.url("opid", opid, "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, opid: 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-05-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}/openidConnectProviders/{opid}", - ) # 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])?$", - ), - "opid": _SERIALIZER.url("opid", opid, "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, opid: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}", - ) # 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])?$", - ), - "opid": _SERIALIZER.url("opid", opid, "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_secrets_request( - resource_group_name: str, service_name: str, opid: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/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])?$", - ), - "opid": _SERIALIZER.url("opid", opid, "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 OpenIdConnectProviderOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`open_id_connect_provider` 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.OpenidConnectProviderContract"]: - """Lists of all the OpenId Connect Providers. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| 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 - :return: An iterator like instance of either OpenidConnectProviderContract or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] - :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.OpenIdConnectProviderCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("OpenIdConnectProviderCollection", 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, opid: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the openIdConnectProvider 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 opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - opid=opid, - 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, opid: str, **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Gets specific OpenID Connect Provider without secrets. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :return: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.OpenidConnectProviderContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - opid=opid, - 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("OpenidConnectProviderContract", 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, - opid: str, - parameters: _models.OpenidConnectProviderContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Creates or updates the OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :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: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - opid: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Creates or updates the OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - opid: str, - parameters: Union[_models.OpenidConnectProviderContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Creates or updates the OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :param parameters: Create parameters. Is either a OpenidConnectProviderContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract 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: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.OpenidConnectProviderContract] = 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, "OpenidConnectProviderContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - opid=opid, - 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("OpenidConnectProviderContract", 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, - opid: str, - if_match: str, - parameters: _models.OpenidConnectProviderUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Updates the specific OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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.OpenidConnectProviderUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - opid: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Updates the specific OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - opid: str, - if_match: str, - parameters: Union[_models.OpenidConnectProviderUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.OpenidConnectProviderContract: - """Updates the specific OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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 OpenidConnectProviderUpdateContract type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract or - IO[bytes] - :return: OpenidConnectProviderContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.OpenidConnectProviderContract] = 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, "OpenidConnectProviderUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - opid=opid, - 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("OpenidConnectProviderContract", 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, opid: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific OpenID Connect Provider 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 opid: Identifier of the OpenID Connect Provider. Required. - :type opid: 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 = { - 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, - opid=opid, - 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_secrets( - self, resource_group_name: str, service_name: str, opid: str, **kwargs: Any - ) -> _models.ClientSecretContract: - """Gets the client secret details of the OpenID Connect Provider. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param opid: Identifier of the OpenID Connect Provider. Required. - :type opid: str - :return: ClientSecretContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.ClientSecretContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_request( - resource_group_name=resource_group_name, - service_name=service_name, - opid=opid, - 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("ClientSecretContract", 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/_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py deleted file mode 100644 index 3fed5bbfce2e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_operations.py +++ /dev/null @@ -1,234 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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_tags_request( - resource_group_name: str, - service_name: str, - api_id: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - include_not_tagged_operations: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags", - ) # 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])?$", - ), - "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 include_not_tagged_operations is not None: - _params["includeNotTaggedOperations"] = _SERIALIZER.query( - "include_not_tagged_operations", include_not_tagged_operations, "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) - - -class OperationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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_tags( - self, - resource_group_name: str, - service_name: str, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - include_not_tagged_operations: Optional[bool] = None, - **kwargs: Any - ) -> Iterable["_models.TagResourceContract"]: - """Lists a collection of operations associated with tags. - - :param resource_group_name: The name of the resource group. The name is 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 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 - |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| method | 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 include_not_tagged_operations: Include not tagged Operations. Default value is None. - :type include_not_tagged_operations: bool - :return: An iterator like instance of either TagResourceContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :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.TagResourceCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_tags_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - include_not_tagged_operations=include_not_tagged_operations, - 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("TagResourceCollection", 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/_operation_status_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_status_operations.py deleted file mode 100644 index b0c108ef528b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operation_status_operations.py +++ /dev/null @@ -1,140 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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 = { - 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.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operations.py new file mode 100644 index 000000000000..3839ff85f157 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operations.py @@ -0,0 +1,107496 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +import datetime +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core import MatchConditions, PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceModifiedError, + 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 .._configuration import ApiManagementClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize +from .._utils.serialization import Deserializer, Serializer +from .._utils.utils import ClientMixinABC, prep_if_match, prep_if_none_match + +JSON = MutableMapping[str, Any] +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +List = list + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_workspace_api_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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_workspace_api_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_api_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if delete_revisions is not None: + _params["deleteRevisions"] = _SERIALIZER.query("delete_revisions", delete_revisions, "bool") + + # Construct headers + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_release_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_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_workspace_api_release_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_api_release_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_release_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_release_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_release_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/releases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_operation_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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_workspace_api_operation_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_api_operation_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_operation_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_operation_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_operation_list_by_api_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_graph_ql_api_resolver_policy_get_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_graph_ql_api_resolver_policy_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_graph_ql_api_resolver_policy_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_graph_ql_api_resolver_policy_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_graph_ql_api_resolver_policy_list_by_resolver_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, api_id: str, resolver_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}/policies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_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_api_policy_get_request( + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_api_policy_get_entity_tag_request( + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_policy_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_policy_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_policy_list_by_api_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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_policy_get_request( + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_policy_get_entity_tag_request( + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_policy_create_or_update_request( + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_delete_request( + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_product_policy_get_request( + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_product_policy_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_product_policy_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_policy_delete_request( + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_policy_list_by_product_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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_workspace_policy_get_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_workspace_policy_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_policy_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_policy_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_policy_list_by_api_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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_workspace_api_operation_policy_get_request( # pylint: disable=name-too-long + 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: Optional[Union[str, _models.PolicyExportFormat]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_workspace_api_operation_policy_get_entity_tag_request( # pylint: disable=name-too-long + 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: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_api_operation_policy_create_or_update_request( # pylint: disable=name-too-long + 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, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_operation_policy_delete_request( # pylint: disable=name-too-long + 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, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_operation_policy_list_by_operation_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/operations/{operationId}/policies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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_workspace_api_policy_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: Optional[Union[str, _models.PolicyExportFormat]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_workspace_api_policy_get_entity_tag_request( # pylint: disable=name-too-long + 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: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_api_policy_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_policy_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_policy_list_by_api_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/policies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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_workspace_product_policy_get_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_workspace_product_policy_get_entity_tag_request( # pylint: disable=name-too-long + 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: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_product_policy_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_product_policy_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_product_policy_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/policies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_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_tag_get_by_api_request( + resource_group_name: str, service_name: str, api_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_tag_get_entity_state_by_api_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, api_id: str, tag_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_tag_assign_to_api_request( + resource_group_name: str, service_name: str, api_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_tag_detach_from_api_request( + resource_group_name: str, service_name: str, api_id: str, tag_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_tag_list_by_api_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tag_get_by_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_tag_get_entity_state_by_operation_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_tag_assign_to_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_tag_detach_from_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_tag_list_by_operation_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tag_get_by_product_request( + resource_group_name: str, service_name: str, product_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_tag_get_entity_state_by_product_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, product_id: str, tag_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_tag_assign_to_product_request( + resource_group_name: str, service_name: str, product_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_tag_detach_from_product_request( + resource_group_name: str, service_name: str, product_id: str, tag_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_tag_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tag_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_tag_get_entity_state_request( + resource_group_name: str, service_name: str, tag_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_tag_create_or_update_request( + resource_group_name: str, + service_name: str, + tag_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tag_update_request( + resource_group_name: str, + service_name: str, + tag_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tag_delete_request( + resource_group_name: str, + service_name: str, + tag_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tag_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, + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if scope is not None: + _params["scope"] = _SERIALIZER.query("scope", scope, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_tag_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_workspace_tag_get_entity_state_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, tag_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_tag_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_tag_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_tag_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_tag_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if scope is not None: + _params["scope"] = _SERIALIZER.query("scope", scope, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_schema_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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_workspace_api_schema_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_api_schema_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_schema_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + schema_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_schema_list_by_api_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/schemas" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_diagnostic_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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_diagnostic_get_entity_tag_request( + resource_group_name: str, service_name: str, diagnostic_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_diagnostic_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_diagnostic_update_request( + resource_group_name: str, + service_name: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_diagnostic_delete_request( + resource_group_name: str, + service_name: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_diagnostic_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_diagnostic_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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_workspace_diagnostic_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_diagnostic_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_diagnostic_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_diagnostic_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_diagnostic_list_by_workspace_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/diagnostics" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_diagnostic_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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_workspace_api_diagnostic_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_api_diagnostic_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_diagnostic_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_diagnostic_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_diagnostic_list_by_workspace_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/diagnostics" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_issue_get_request( + resource_group_name: str, service_name: str, issue_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_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_issue_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_wiki_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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_product_wiki_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, product_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_product_wiki_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_wiki_update_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_wiki_delete_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_version_set_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_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_workspace_api_version_set_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_api_version_set_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_version_set_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_version_set_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_version_set_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apiVersionSets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_backend_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_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_workspace_backend_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, backend_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_backend_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_backend_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_backend_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_backend_list_by_workspace_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/backends" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_certificate_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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_workspace_certificate_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_certificate_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_certificate_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_certificate_list_by_workspace_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if is_key_vault_refresh_failed is not None: + _params["isKeyVaultRefreshFailed"] = _SERIALIZER.query( + "is_key_vault_refresh_failed", is_key_vault_refresh_failed, "bool" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_certificate_refresh_secret_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/certificates/{certificateId}/refreshSecret" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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_workspace_group_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_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_workspace_group_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, group_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_group_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_group_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_group_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_group_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_logger_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_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_workspace_logger_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, logger_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_logger_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_logger_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_logger_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_logger_list_by_workspace_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/loggers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_named_value_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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_workspace_named_value_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_named_value_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_named_value_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_named_value_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_named_value_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if is_key_vault_refresh_failed is not None: + _params["isKeyVaultRefreshFailed"] = _SERIALIZER.query( + "is_key_vault_refresh_failed", is_key_vault_refresh_failed, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_named_value_list_value_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}/listValue" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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_workspace_named_value_refresh_secret_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/namedValues/{namedValueId}/refreshSecret" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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_workspace_notification_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "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_workspace_notification_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_notification_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_policy_fragment_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "id": _SERIALIZER.url("id", 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_workspace_policy_fragment_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_policy_fragment_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "id": _SERIALIZER.url("id", 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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_policy_fragment_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "id": _SERIALIZER.url("id", 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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_policy_fragment_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_policy_fragment_list_references_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/policyFragments/{id}/listReferences" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "id": _SERIALIZER.url("id", 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") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sign_in_settings_get_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_sign_in_settings_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_sign_in_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sign_in_settings_update_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sign_up_settings_get_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_sign_up_settings_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_sign_up_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_sign_up_settings_update_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delegation_settings_get_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_delegation_settings_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_delegation_settings_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delegation_settings_update_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delegation_settings_list_secrets_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_workspace_product_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_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_workspace_product_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, product_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_product_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_product_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_product_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if delete_subscriptions is not None: + _params["deleteSubscriptions"] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, "bool") + + # Construct headers + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_product_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_product_api_link_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_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_workspace_product_api_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_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_workspace_product_api_link_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + api_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workspace_product_api_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/apiLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_product_group_link_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks/{groupLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "groupLinkId": _SERIALIZER.url("group_link_id", group_link_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_workspace_product_group_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks/{groupLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "groupLinkId": _SERIALIZER.url("group_link_id", group_link_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_workspace_product_group_link_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + group_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks/{groupLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "groupLinkId": _SERIALIZER.url("group_link_id", group_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workspace_product_group_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/products/{productId}/groupLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "productId": _SERIALIZER.url("product_id", product_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_global_schema_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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_workspace_global_schema_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, schema_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_global_schema_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_global_schema_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_global_schema_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/schemas" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_user_subscription_get_request( + resource_group_name: str, service_name: str, user_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + "sid": _SERIALIZER.url("sid", sid, "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_user_subscription_list_request( + resource_group_name: str, + service_name: str, + user_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_subscription_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "sid": _SERIALIZER.url("sid", sid, "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_workspace_subscription_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_subscription_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + subscription_id: str, + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if notify is not None: + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + if app_type is not None: + _params["appType"] = _SERIALIZER.query("app_type", app_type, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_subscription_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if notify is not None: + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + if app_type is not None: + _params["appType"] = _SERIALIZER.query("app_type", app_type, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_subscription_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + sid: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "sid": _SERIALIZER.url("sid", sid, "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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_subscription_list_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_subscription_regenerate_primary_key_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}/regeneratePrimaryKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_workspace_subscription_regenerate_secondary_key_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, workspace_id: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}/regenerateSecondaryKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_workspace_subscription_list_secrets_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/subscriptions/{sid}/listSecrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "sid": _SERIALIZER.url("sid", sid, "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_workspace_tag_api_link_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_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_workspace_tag_api_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_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_workspace_tag_api_link_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + api_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workspace_tag_api_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/apiLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_tag_operation_link_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks/{operationLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "operationLinkId": _SERIALIZER.url("operation_link_id", operation_link_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_workspace_tag_operation_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks/{operationLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "operationLinkId": _SERIALIZER.url("operation_link_id", operation_link_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_workspace_tag_operation_link_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + operation_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks/{operationLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "operationLinkId": _SERIALIZER.url("operation_link_id", operation_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workspace_tag_operation_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/operationLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_tag_product_link_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks/{productLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "productLinkId": _SERIALIZER.url("product_link_id", product_link_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_workspace_tag_product_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks/{productLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "productLinkId": _SERIALIZER.url("product_link_id", product_link_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_workspace_tag_product_link_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + product_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks/{productLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "productLinkId": _SERIALIZER.url("product_link_id", product_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workspace_tag_product_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/tags/{tagId}/productLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_management_operations_list_request(**kwargs: Any) -> HttpRequest: # 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.ApiManagement/operations" + + # 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_api_gateway_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "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_api_gateway_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "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_api_gateway_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "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_api_gateway_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "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_api_gateway_list_by_resource_group_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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_api_gateway_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _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) + + +def build_api_management_gateway_skus_list_available_skus_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/skus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "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_api_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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_api_get_entity_tag_request( + resource_group_name: str, service_name: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if delete_revisions is not None: + _params["deleteRevisions"] = _SERIALIZER.query("delete_revisions", delete_revisions, "bool") + + # Construct headers + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_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, + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_list_by_tags_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_apis: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if include_not_tagged_apis is not None: + _params["includeNotTaggedApis"] = _SERIALIZER.query("include_not_tagged_apis", include_not_tagged_apis, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_revision_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_product_list_by_apis_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_operation_list_by_tags_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_operations: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if include_not_tagged_operations is not None: + _params["includeNotTaggedOperations"] = _SERIALIZER.query( + "include_not_tagged_operations", include_not_tagged_operations, "bool" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_api_revision_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}/revisions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_management_service_get_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_delete_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_list_by_resource_group_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = ( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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_api_management_service_list_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service" + 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) + + +def build_api_management_service_restore_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_backup_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_migrate_to_stv2_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/migrateToStv2" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_get_sso_token_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_apply_network_configuration_updates_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_refresh_hostnames_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/refreshHostnames" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_check_name_availability_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability" + 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 + 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_api_management_service_get_domain_ownership_identifier_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier" + 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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_all_policies_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/allPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_api_management_service_skus_list_available_service_skus_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_network_status_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_network_status_list_by_location_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, location_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "locationName": _SERIALIZER.url("location_name", location_name, "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_outbound_network_dependencies_endpoints_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/outboundNetworkDependenciesEndpoints" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_policy_description_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + scope: Optional[Union[str, _models.PolicyScopeContract]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if scope is not None: + _params["scope"] = _SERIALIZER.query("scope", scope, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_restriction_validations_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/validatePolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_portal_settings_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_product_list_by_tags_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_products: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if include_not_tagged_products is not None: + _params["includeNotTaggedProducts"] = _SERIALIZER.query( + "include_not_tagged_products", include_not_tagged_products, "bool" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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_product_get_entity_tag_request( + resource_group_name: str, service_name: str, product_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_product_create_or_update_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_update_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_delete_request( + resource_group_name: str, + service_name: str, + product_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if delete_subscriptions is not None: + _params["deleteSubscriptions"] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, "bool") + + # Construct headers + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_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, + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_quota_by_counter_keys_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, quota_counter_key: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "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_quota_by_counter_keys_update_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, quota_counter_key: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "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_quota_by_period_keys_get_request( + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "str"), + "quotaPeriodKey": _SERIALIZER.url("quota_period_key", quota_period_key, "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_quota_by_period_keys_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "str"), + "quotaPeriodKey": _SERIALIZER.url("quota_period_key", quota_period_key, "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_region_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_reports_list_by_api_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reports_list_by_user_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reports_list_by_operation_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reports_list_by_product_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reports_list_by_geo_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reports_list_by_subscription_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reports_list_by_time_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: str, + interval: datetime.timedelta, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if orderby is not None: + _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") + _params["interval"] = _SERIALIZER.query("interval", interval, "duration") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_reports_list_by_request_request( + resource_group_name: str, + service_name: str, + subscription_id: str, + *, + filter: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tag_resource_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_release_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_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_api_release_get_entity_tag_request( + resource_group_name: str, service_name: str, api_id: str, release_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_release_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_release_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_release_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "releaseId": _SERIALIZER.url("release_id", release_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_release_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_operation_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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_api_operation_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, api_id: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_operation_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_operation_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_operation_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_operation_list_by_api_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if tags is not None: + _params["tags"] = _SERIALIZER.query("tags", tags, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_operation_policy_get_request( + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_api_operation_policy_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_operation_policy_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_operation_policy_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "policyId": _SERIALIZER.url("policy_id", policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_operation_policy_list_by_operation_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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_graph_ql_api_resolver_get_request( + resource_group_name: str, service_name: str, api_id: str, resolver_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_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_graph_ql_api_resolver_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, api_id: str, resolver_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_graph_ql_api_resolver_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_graph_ql_api_resolver_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_graph_ql_api_resolver_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers/{resolverId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "resolverId": _SERIALIZER.url("resolver_id", resolver_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_graph_ql_api_resolver_list_by_api_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/resolvers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_schema_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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_api_schema_get_entity_tag_request( + resource_group_name: str, service_name: str, api_id: str, schema_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_schema_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_schema_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_schema_list_by_api_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_diagnostic_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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_api_diagnostic_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, api_id: str, diagnostic_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_diagnostic_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_diagnostic_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_diagnostic_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "diagnosticId": _SERIALIZER.url("diagnostic_id", diagnostic_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_diagnostic_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_get_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + subscription_id: str, + *, + expand_comments_attachments: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand_comments_attachments is not None: + _params["expandCommentsAttachments"] = _SERIALIZER.query( + "expand_comments_attachments", expand_comments_attachments, "bool" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_get_entity_tag_request( + resource_group_name: str, service_name: str, api_id: str, issue_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_issue_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_list_by_service_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + expand_comments_attachments: Optional[bool] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 expand_comments_attachments is not None: + _params["expandCommentsAttachments"] = _SERIALIZER.query( + "expand_comments_attachments", expand_comments_attachments, "bool" + ) + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_comment_get_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + "commentId": _SERIALIZER.url("comment_id", comment_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_api_issue_comment_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + "commentId": _SERIALIZER.url("comment_id", comment_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_issue_comment_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + "commentId": _SERIALIZER.url("comment_id", comment_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_comment_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + "commentId": _SERIALIZER.url("comment_id", comment_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_comment_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + issue_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_attachment_get_request( + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + "attachmentId": _SERIALIZER.url("attachment_id", attachment_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_api_issue_attachment_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + "attachmentId": _SERIALIZER.url("attachment_id", attachment_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_issue_attachment_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + "attachmentId": _SERIALIZER.url("attachment_id", attachment_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_attachment_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_id, "str"), + "attachmentId": _SERIALIZER.url("attachment_id", attachment_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_issue_attachment_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + issue_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "issueId": _SERIALIZER.url("issue_id", issue_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_tag_description_get_request( + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "tagDescriptionId": _SERIALIZER.url("tag_description_id", tag_description_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_api_tag_description_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "tagDescriptionId": _SERIALIZER.url("tag_description_id", tag_description_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_tag_description_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "tagDescriptionId": _SERIALIZER.url("tag_description_id", tag_description_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_tag_description_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "tagDescriptionId": _SERIALIZER.url("tag_description_id", tag_description_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_tag_description_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_wiki_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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_api_wiki_get_entity_tag_request( + resource_group_name: str, service_name: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_wiki_create_or_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_wiki_update_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_wiki_delete_request( + resource_group_name: str, + service_name: str, + api_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis/default" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_wikis_list_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/wikis" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_wikis_list_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/wikis" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_tool_get_request( + resource_group_name: str, service_name: str, api_id: str, tool_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tools/{toolId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "toolId": _SERIALIZER.url("tool_id", tool_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_api_tool_get_entity_tag_request( + resource_group_name: str, service_name: str, api_id: str, tool_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tools/{toolId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "toolId": _SERIALIZER.url("tool_id", tool_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_tool_create_or_update_request( + resource_group_name: str, service_name: str, api_id: str, tool_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tools/{toolId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "toolId": _SERIALIZER.url("tool_id", tool_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_api_tool_update_request( + resource_group_name: str, service_name: str, api_id: str, tool_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tools/{toolId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "toolId": _SERIALIZER.url("tool_id", tool_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_api_tool_delete_request( + resource_group_name: str, service_name: str, api_id: str, tool_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tools/{toolId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + "toolId": _SERIALIZER.url("tool_id", tool_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_api_tool_list_by_api_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tools" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_version_set_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_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_api_version_set_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, version_set_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_api_version_set_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + version_set_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_version_set_update_request( + resource_group_name: str, + service_name: str, + version_set_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_version_set_delete_request( + resource_group_name: str, + service_name: str, + version_set_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "versionSetId": _SERIALIZER.url("version_set_id", version_set_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_version_set_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_provider_get_request( + resource_group_name: str, service_name: str, authorization_provider_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_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_authorization_provider_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_provider_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_provider_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_provider_refresh_secret_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, authorization_provider_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/refreshSecret" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_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_authorization_get_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, "str"), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_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_authorization_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, "str"), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_delete_request( + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, "str"), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_list_by_authorization_provider_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_confirm_consent_code_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/confirmConsentCode" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, "str"), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_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") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_login_links_post_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/getLoginLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, "str"), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_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_authorization_access_policy_get_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies/{authorizationAccessPolicyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, "str"), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, "str"), + "authorizationAccessPolicyId": _SERIALIZER.url( + "authorization_access_policy_id", authorization_access_policy_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_authorization_access_policy_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies/{authorizationAccessPolicyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, "str"), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, "str"), + "authorizationAccessPolicyId": _SERIALIZER.url( + "authorization_access_policy_id", authorization_access_policy_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_access_policy_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies/{authorizationAccessPolicyId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, "str"), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_id, "str"), + "authorizationAccessPolicyId": _SERIALIZER.url( + "authorization_access_policy_id", authorization_access_policy_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_access_policy_list_by_authorization_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationProviders/{authorizationProviderId}/authorizations/{authorizationId}/accessPolicies" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authorizationProviderId": _SERIALIZER.url("authorization_provider_id", authorization_provider_id, "str"), + "authorizationId": _SERIALIZER.url("authorization_id", authorization_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_server_get_request( + resource_group_name: str, service_name: str, authsid: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authsid": _SERIALIZER.url("authsid", authsid, "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_authorization_server_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, authsid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authsid": _SERIALIZER.url("authsid", authsid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_authorization_server_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authsid: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authsid": _SERIALIZER.url("authsid", authsid, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_server_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authsid: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authsid": _SERIALIZER.url("authsid", authsid, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_server_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + authsid: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authsid": _SERIALIZER.url("authsid", authsid, "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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_server_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_authorization_server_list_secrets_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, authsid: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "authsid": _SERIALIZER.url("authsid", authsid, "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_backend_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_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_backend_get_entity_tag_request( + resource_group_name: str, service_name: str, backend_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_backend_create_or_update_request( + resource_group_name: str, + service_name: str, + backend_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backend_update_request( + resource_group_name: str, + service_name: str, + backend_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backend_delete_request( + resource_group_name: str, + service_name: str, + backend_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backend_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backend_reconnect_request( + resource_group_name: str, service_name: 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "backendId": _SERIALIZER.url("backend_id", backend_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") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cache_get_request( + resource_group_name: str, service_name: str, cache_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "cacheId": _SERIALIZER.url("cache_id", cache_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_cache_get_entity_tag_request( + resource_group_name: str, service_name: str, cache_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "cacheId": _SERIALIZER.url("cache_id", cache_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_cache_create_or_update_request( + resource_group_name: str, + service_name: str, + cache_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "cacheId": _SERIALIZER.url("cache_id", cache_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cache_update_request( + resource_group_name: str, + service_name: str, + cache_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "cacheId": _SERIALIZER.url("cache_id", cache_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cache_delete_request( + resource_group_name: str, + service_name: str, + cache_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "cacheId": _SERIALIZER.url("cache_id", cache_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_cache_list_by_service_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_certificate_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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_certificate_get_entity_tag_request( + resource_group_name: str, service_name: str, certificate_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_certificate_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + certificate_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_certificate_delete_request( + resource_group_name: str, + service_name: str, + certificate_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_certificate_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if is_key_vault_refresh_failed is not None: + _params["isKeyVaultRefreshFailed"] = _SERIALIZER.query( + "is_key_vault_refresh_failed", is_key_vault_refresh_failed, "bool" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_certificate_refresh_secret_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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_content_type_get_request( + resource_group_name: str, service_name: str, content_type_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "contentTypeId": _SERIALIZER.url("content_type_id", content_type_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_content_type_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + content_type_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "contentTypeId": _SERIALIZER.url("content_type_id", content_type_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_content_type_delete_request( + resource_group_name: str, + service_name: str, + content_type_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "contentTypeId": _SERIALIZER.url("content_type_id", content_type_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_content_type_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_content_item_get_request( + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str"), + "contentItemId": _SERIALIZER.url("content_item_id", content_item_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_content_item_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str"), + "contentItemId": _SERIALIZER.url("content_item_id", content_item_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_content_item_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str"), + "contentItemId": _SERIALIZER.url("content_item_id", content_item_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_content_item_delete_request( + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "contentTypeId": _SERIALIZER.url("content_type_id", content_type_id, "str"), + "contentItemId": _SERIALIZER.url("content_item_id", content_item_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_content_item_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, content_type_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "contentTypeId": _SERIALIZER.url("content_type_id", content_type_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_deleted_services_get_by_name_request( # pylint: disable=name-too-long + service_name: str, location: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}" + path_format_arguments = { + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "location": _SERIALIZER.url("location", location, "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_deleted_services_purge_request( + service_name: str, location: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}" + path_format_arguments = { + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "location": _SERIALIZER.url("location", location, "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) + + +def build_deleted_services_list_by_subscription_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices" + 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) + + +def build_documentation_get_request( + resource_group_name: str, service_name: str, documentation_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "documentationId": _SERIALIZER.url("documentation_id", documentation_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_documentation_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, documentation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "documentationId": _SERIALIZER.url("documentation_id", documentation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_documentation_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + documentation_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "documentationId": _SERIALIZER.url("documentation_id", documentation_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_documentation_update_request( + resource_group_name: str, + service_name: str, + documentation_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "documentationId": _SERIALIZER.url("documentation_id", documentation_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_documentation_delete_request( + resource_group_name: str, + service_name: str, + documentation_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations/{documentationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "documentationId": _SERIALIZER.url("documentation_id", documentation_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_documentation_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/documentations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_email_template_get_request( + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "templateName": _SERIALIZER.url("template_name", template_name, "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_email_template_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "templateName": _SERIALIZER.url("template_name", template_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_email_template_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "templateName": _SERIALIZER.url("template_name", template_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_email_template_update_request( + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "templateName": _SERIALIZER.url("template_name", template_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_email_template_delete_request( + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "templateName": _SERIALIZER.url("template_name", template_name, "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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_email_template_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_gateway_config_connection_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections/{configConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "configConnectionName": _SERIALIZER.url("config_connection_name", config_connection_name, "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_api_gateway_config_connection_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections/{configConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "configConnectionName": _SERIALIZER.url("config_connection_name", config_connection_name, "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_api_gateway_config_connection_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + gateway_name: str, + config_connection_name: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections/{configConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "configConnectionName": _SERIALIZER.url("config_connection_name", config_connection_name, "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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_gateway_config_connection_list_by_gateway_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/configConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "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_api_gateway_hostname_binding_get_request( # pylint: disable=name-too-long + resource_group_name: str, gateway_name: str, hostname_binding_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/hostnameBindings/{hostnameBindingName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "hostnameBindingName": _SERIALIZER.url("hostname_binding_name", hostname_binding_name, "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_api_gateway_hostname_binding_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/hostnameBindings/{hostnameBindingName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "hostnameBindingName": _SERIALIZER.url("hostname_binding_name", hostname_binding_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_gateway_hostname_binding_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/hostnameBindings/{hostnameBindingName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "hostnameBindingName": _SERIALIZER.url("hostname_binding_name", hostname_binding_name, "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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_gateway_hostname_binding_list_by_gateway_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/hostnameBindings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "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_api_gateway_hostname_binding_refresh_secret_request( # pylint: disable=name-too-long + resource_group_name: str, gateway_name: str, hostname_binding_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/gateways/{gatewayName}/hostnameBindings/{hostnameBindingName}/refreshSecret" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "gatewayName": _SERIALIZER.url("gateway_name", gateway_name, "str"), + "hostnameBindingName": _SERIALIZER.url("hostname_binding_name", hostname_binding_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_gateway_get_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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_gateway_get_entity_tag_request( + resource_group_name: str, service_name: str, gateway_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_gateway_create_or_update_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_update_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_delete_request( + resource_group_name: str, + service_name: str, + gateway_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_list_keys_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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_gateway_regenerate_key_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_generate_token_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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_gateway_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: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/invalidateDebugCredentials" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_gateway_list_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listDebugCredentials" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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_gateway_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listTrace" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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_gateway_api_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + gateway_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_api_get_entity_tag_request( + resource_group_name: str, service_name: str, gateway_id: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_gateway_api_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, gateway_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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_gateway_api_delete_request( + resource_group_name: str, service_name: str, gateway_id: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_gateway_hostname_configuration_get_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, gateway_id: str, hc_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "hcId": _SERIALIZER.url("hc_id", hc_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_gateway_hostname_configuration_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, gateway_id: str, hc_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "hcId": _SERIALIZER.url("hc_id", hc_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_gateway_hostname_configuration_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "hcId": _SERIALIZER.url("hc_id", hc_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_hostname_configuration_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "hcId": _SERIALIZER.url("hc_id", hc_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_hostname_configuration_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + gateway_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_certificate_authority_get_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + gateway_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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_gateway_certificate_authority_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_gateway_certificate_authority_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_certificate_authority_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_id, "str"), + "certificateId": _SERIALIZER.url("certificate_id", certificate_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_gateway_certificate_authority_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + gateway_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_group_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_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_group_get_entity_tag_request( + resource_group_name: str, service_name: str, group_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_group_create_or_update_request( + resource_group_name: str, + service_name: str, + group_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_group_update_request( + resource_group_name: str, + service_name: str, + group_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_group_delete_request( + resource_group_name: str, + service_name: str, + group_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_group_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_group_user_list_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_group_user_check_entity_exists_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, group_id: str, user_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_group_user_create_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + "userId": _SERIALIZER.url("user_id", user_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_group_user_delete_request( + resource_group_name: str, service_name: str, group_id: str, user_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workspace_group_user_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_group_user_check_entity_exists_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_group_user_create_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + "userId": _SERIALIZER.url("user_id", user_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_workspace_group_user_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/groups/{groupId}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_identity_provider_get_request( + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "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_identity_provider_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_identity_provider_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_identity_provider_update_request( + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_identity_provider_delete_request( + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_identity_provider_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_identity_provider_list_secrets_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "identityProviderName": _SERIALIZER.url("identity_provider_name", identity_provider_name, "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_logger_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_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_logger_get_entity_tag_request( + resource_group_name: str, service_name: str, logger_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_logger_create_or_update_request( + resource_group_name: str, + service_name: str, + logger_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_logger_update_request( + resource_group_name: str, + service_name: str, + logger_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_logger_delete_request( + resource_group_name: str, + service_name: str, + logger_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "loggerId": _SERIALIZER.url("logger_id", logger_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_logger_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_named_value_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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_named_value_get_entity_tag_request( + resource_group_name: str, service_name: str, named_value_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_named_value_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + named_value_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_named_value_update_request( + resource_group_name: str, + service_name: str, + named_value_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_named_value_delete_request( + resource_group_name: str, + service_name: str, + named_value_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_named_value_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if is_key_vault_refresh_failed is not None: + _params["isKeyVaultRefreshFailed"] = _SERIALIZER.query( + "is_key_vault_refresh_failed", is_key_vault_refresh_failed, "bool" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_named_value_list_value_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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_named_value_refresh_secret_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "namedValueId": _SERIALIZER.url("named_value_id", named_value_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_notification_get_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "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_notification_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + notification_name: Union[str, _models.NotificationName], + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_notification_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_notification_recipient_user_list_by_notification_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "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_notification_recipient_user_check_entity_exists_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_notification_recipient_user_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "userId": _SERIALIZER.url("user_id", user_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_notification_recipient_user_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + notification_name: Union[str, _models.NotificationName], + user_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_notification_recipient_email_list_by_notification_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "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_notification_recipient_email_check_entity_exists_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + notification_name: Union[str, _models.NotificationName], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_notification_recipient_email_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "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_notification_recipient_email_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + notification_name: Union[str, _models.NotificationName], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workspace_notification_recipient_user_list_by_notification_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "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_workspace_notification_recipient_user_check_entity_exists_request( # pylint: disable=name-too-long + 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: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_notification_recipient_user_create_or_update_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "userId": _SERIALIZER.url("user_id", user_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_workspace_notification_recipient_user_delete_request( # pylint: disable=name-too-long + 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: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientUsers/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_workspace_notification_recipient_email_list_by_notification_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "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_workspace_notification_recipient_email_check_entity_exists_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails/{email}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_notification_recipient_email_create_or_update_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails/{email}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "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_workspace_notification_recipient_email_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + workspace_id: str, + notification_name: Union[str, _models.NotificationName], + email: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/notifications/{notificationName}/recipientEmails/{email}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "notificationName": _SERIALIZER.url("notification_name", notification_name, "str"), + "email": _SERIALIZER.url("email", email, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_open_id_connect_provider_get_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, opid: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "opid": _SERIALIZER.url("opid", opid, "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_open_id_connect_provider_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, opid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "opid": _SERIALIZER.url("opid", opid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_open_id_connect_provider_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + opid: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "opid": _SERIALIZER.url("opid", opid, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_open_id_connect_provider_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + opid: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "opid": _SERIALIZER.url("opid", opid, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_open_id_connect_provider_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + opid: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "opid": _SERIALIZER.url("opid", opid, "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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_open_id_connect_provider_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_open_id_connect_provider_list_secrets_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, opid: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "opid": _SERIALIZER.url("opid", opid, "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_policy_fragment_get_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "id": _SERIALIZER.url("id", 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_policy_fragment_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_policy_fragment_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "id": _SERIALIZER.url("id", 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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_fragment_delete_request( + resource_group_name: str, + service_name: str, + id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "id": _SERIALIZER.url("id", 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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_fragment_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_fragment_list_references_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyFragments/{id}/listReferences" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "id": _SERIALIZER.url("id", 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") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_restriction_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "policyRestrictionId": _SERIALIZER.url("policy_restriction_id", policy_restriction_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_policy_restriction_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, policy_restriction_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "policyRestrictionId": _SERIALIZER.url("policy_restriction_id", policy_restriction_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_policy_restriction_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "policyRestrictionId": _SERIALIZER.url("policy_restriction_id", policy_restriction_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_restriction_update_request( + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "policyRestrictionId": _SERIALIZER.url("policy_restriction_id", policy_restriction_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_restriction_delete_request( + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions/{policyRestrictionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "policyRestrictionId": _SERIALIZER.url("policy_restriction_id", policy_restriction_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_restriction_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyRestrictions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_portal_config_get_request( + resource_group_name: str, service_name: str, portal_config_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_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_portal_config_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, portal_config_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_portal_config_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + portal_config_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_portal_config_update_request( + resource_group_name: str, + service_name: str, + portal_config_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs/{portalConfigId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_portal_config_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_client_application_get_request( + resource_group_name: str, service_name: str, client_application_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications/{clientApplicationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "clientApplicationId": _SERIALIZER.url("client_application_id", client_application_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_client_application_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, client_application_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications/{clientApplicationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "clientApplicationId": _SERIALIZER.url("client_application_id", client_application_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_client_application_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, client_application_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications/{clientApplicationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "clientApplicationId": _SERIALIZER.url("client_application_id", client_application_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_client_application_delete_request( + resource_group_name: str, service_name: str, client_application_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications/{clientApplicationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "clientApplicationId": _SERIALIZER.url("client_application_id", client_application_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_client_application_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_client_application_list_secrets_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, client_application_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications/{clientApplicationId}/listSecrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "clientApplicationId": _SERIALIZER.url("client_application_id", client_application_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_client_application_product_link_get_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications/{clientApplicationId}/productLinks/{clientApplicationProductLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "clientApplicationId": _SERIALIZER.url("client_application_id", client_application_id, "str"), + "clientApplicationProductLinkId": _SERIALIZER.url( + "client_application_product_link_id", client_application_product_link_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_client_application_product_link_create_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications/{clientApplicationId}/productLinks/{clientApplicationProductLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "clientApplicationId": _SERIALIZER.url("client_application_id", client_application_id, "str"), + "clientApplicationProductLinkId": _SERIALIZER.url( + "client_application_product_link_id", client_application_product_link_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_client_application_product_link_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications/{clientApplicationId}/productLinks/{clientApplicationProductLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "clientApplicationId": _SERIALIZER.url("client_application_id", client_application_id, "str"), + "clientApplicationProductLinkId": _SERIALIZER.url( + "client_application_product_link_id", client_application_product_link_id, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_client_application_product_link_list_by_client_applications_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + client_application_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/clientApplications/{clientApplicationId}/productLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "clientApplicationId": _SERIALIZER.url("client_application_id", client_application_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") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_portal_revision_get_request( + resource_group_name: str, service_name: str, portal_revision_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "portalRevisionId": _SERIALIZER.url("portal_revision_id", portal_revision_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_portal_revision_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, portal_revision_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "portalRevisionId": _SERIALIZER.url("portal_revision_id", portal_revision_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_portal_revision_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, portal_revision_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "portalRevisionId": _SERIALIZER.url("portal_revision_id", portal_revision_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_portal_revision_update_request( + resource_group_name: str, + service_name: str, + portal_revision_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "portalRevisionId": _SERIALIZER.url("portal_revision_id", portal_revision_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_portal_revision_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_private_endpoint_connection_get_by_name_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + private_endpoint_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "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_private_endpoint_connection_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + private_endpoint_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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "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_private_endpoint_connection_delete_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_private_endpoint_connection_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_private_endpoint_connection_get_private_link_resource_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + private_link_sub_resource_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "privateLinkSubResourceName": _SERIALIZER.url( + "private_link_sub_resource_name", private_link_sub_resource_name, "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_private_endpoint_connection_list_private_link_resources_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_product_api_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_api_check_entity_exists_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, product_id: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_product_api_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, product_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_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_product_api_delete_request( + resource_group_name: str, service_name: str, product_id: str, api_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_product_group_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_group_check_entity_exists_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, product_id: str, group_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_product_group_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, product_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_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_product_group_delete_request( + resource_group_name: str, service_name: str, product_id: str, group_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_product_subscriptions_list_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_api_link_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_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_product_api_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_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_product_api_link_delete_request( + resource_group_name: str, service_name: str, product_id: str, api_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_product_api_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apiLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_product_group_link_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks/{groupLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "groupLinkId": _SERIALIZER.url("group_link_id", group_link_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_product_group_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks/{groupLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "groupLinkId": _SERIALIZER.url("group_link_id", group_link_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_product_group_link_delete_request( + resource_group_name: str, + service_name: str, + product_id: str, + group_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks/{groupLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_id, "str"), + "groupLinkId": _SERIALIZER.url("group_link_id", group_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_product_group_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groupLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "productId": _SERIALIZER.url("product_id", product_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_global_schema_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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_global_schema_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, schema_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_global_schema_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + schema_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_global_schema_delete_request( + resource_group_name: str, + service_name: str, + schema_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas/{schemaId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "schemaId": _SERIALIZER.url("schema_id", schema_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_global_schema_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/schemas" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenant_settings_get_request( + resource_group_name: str, + service_name: str, + settings_type: Union[str, _models.SettingsTypeName], + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "settingsType": _SERIALIZER.url("settings_type", settings_type, "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_tenant_settings_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, subscription_id: str, *, filter: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "sid": _SERIALIZER.url("sid", sid, "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_subscription_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_subscription_create_or_update_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + sid: str, + subscription_id: str, + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if notify is not None: + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + if app_type is not None: + _params["appType"] = _SERIALIZER.query("app_type", app_type, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_update_request( + resource_group_name: str, + service_name: str, + sid: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if notify is not None: + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + if app_type is not None: + _params["appType"] = _SERIALIZER.query("app_type", app_type, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_delete_request( + resource_group_name: str, + service_name: str, + sid: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "sid": _SERIALIZER.url("sid", sid, "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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_list_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_subscription_regenerate_primary_key_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_subscription_regenerate_secondary_key_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, sid: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "sid": _SERIALIZER.url("sid", sid, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_subscription_list_secrets_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "sid": _SERIALIZER.url("sid", sid, "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_tag_api_link_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_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_tag_api_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_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_tag_api_link_delete_request( + resource_group_name: str, service_name: str, tag_id: str, api_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks/{apiLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "apiLinkId": _SERIALIZER.url("api_link_id", api_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_tag_api_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/apiLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tag_operation_link_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks/{operationLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "operationLinkId": _SERIALIZER.url("operation_link_id", operation_link_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_tag_operation_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks/{operationLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "operationLinkId": _SERIALIZER.url("operation_link_id", operation_link_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_tag_operation_link_delete_request( + resource_group_name: str, + service_name: str, + tag_id: str, + operation_link_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks/{operationLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "operationLinkId": _SERIALIZER.url("operation_link_id", operation_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_tag_operation_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/operationLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tag_product_link_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks/{productLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "productLinkId": _SERIALIZER.url("product_link_id", product_link_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_tag_product_link_create_or_update_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks/{productLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "productLinkId": _SERIALIZER.url("product_link_id", product_link_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_tag_product_link_delete_request( + resource_group_name: str, service_name: str, tag_id: str, product_link_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks/{productLinkId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_id, "str"), + "productLinkId": _SERIALIZER.url("product_link_id", product_link_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_tag_product_link_list_by_product_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}/productLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "tagId": _SERIALIZER.url("tag_id", tag_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenant_access_get_request( + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "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_tenant_access_get_entity_tag_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_tenant_access_create_request( + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenant_access_update_request( + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenant_access_list_by_service_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: str, subscription_id: str, *, filter: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_tenant_access_regenerate_primary_key_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_tenant_access_regenerate_secondary_key_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_tenant_access_list_secrets_request( + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "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_tenant_access_git_regenerate_primary_key_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_tenant_access_git_regenerate_secondary_key_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "accessName": _SERIALIZER.url("access_name", access_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_tenant_configuration_deploy_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "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_tenant_configuration_save_request( + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "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_tenant_configuration_validate_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "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_tenant_configuration_get_sync_state_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "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_user_get_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_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_user_get_entity_tag_request( + resource_group_name: str, service_name: str, user_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_user_create_or_update_request( + resource_group_name: str, + service_name: str, + user_id: str, + subscription_id: str, + *, + notify: Optional[bool] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if notify is not None: + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + + # 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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_user_update_request( + resource_group_name: str, + service_name: str, + user_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_user_delete_request( + resource_group_name: str, + service_name: str, + user_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + delete_subscriptions: Optional[bool] = None, + 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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if delete_subscriptions is not None: + _params["deleteSubscriptions"] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, "bool") + if notify is not None: + _params["notify"] = _SERIALIZER.query("notify", notify, "bool") + if app_type is not None: + _params["appType"] = _SERIALIZER.query("app_type", app_type, "str") + + # Construct headers + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_user_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, + expand_groups: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + if expand_groups is not None: + _params["expandGroups"] = _SERIALIZER.query("expand_groups", expand_groups, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_user_generate_sso_url_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_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_user_get_shared_access_token_request( # pylint: disable=name-too-long + resource_group_name: str, service_name: 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_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_user_group_list_request( + resource_group_name: str, + service_name: str, + user_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_user_identities_list_request( + resource_group_name: str, service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_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_user_confirmation_password_send_request( # pylint: disable=name-too-long + resource_group_name: str, + service_name: str, + user_id: str, + subscription_id: str, + *, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "userId": _SERIALIZER.url("user_id", user_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _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") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_api_management_workspace_link_get_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaceLinks/{workspaceId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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_api_management_workspace_links_list_by_service_request( # pylint: disable=name-too-long + 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaceLinks" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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_workspace_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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_workspace_get_entity_tag_request( + resource_group_name: str, service_name: str, workspace_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="HEAD", url=_url, params=_params, **kwargs) + + +def build_workspace_create_or_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_update_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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") + if_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_delete_request( + resource_group_name: str, + service_name: str, + workspace_id: str, + subscription_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_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_match = prep_if_match(etag, match_condition) + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if_none_match = prep_if_none_match(etag, match_condition) + if if_none_match is not None: + _headers["If-None-Match"] = _SERIALIZER.header("if_none_match", if_none_match, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_workspace_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if skip is not None: + _params["$skip"] = _SERIALIZER.query("skip", skip, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_export_get_request( + resource_group_name: str, + service_name: 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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}?export=true" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["export"] = _SERIALIZER.query("export", export, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_api_management_skus_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus" + 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) + + +def build_workspace_api_export_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces/{workspaceId}/apis/{apiId}?export=true" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "str"), + "workspaceId": _SERIALIZER.url("workspace_id", workspace_id, "str"), + "apiId": _SERIALIZER.url("api_id", api_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["format"] = _SERIALIZER.query("format", format, "str") + _params["export"] = _SERIALIZER.query("export", export, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_operation_status_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", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/operationStatuses/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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_operations_results_get_request( + location: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/operationResults/{operationId}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="GET", url=_url, params=_params, **kwargs) + + +def build_api_management_perform_connectivity_check_async_request( # pylint: disable=name-too-long + 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 {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/connectivityCheck" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "serviceName": _SERIALIZER.url("service_name", service_name, "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) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, **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. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns ApiContract. The ApiContract is compatible with + MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns ApiContract. The ApiContract is compatible with + MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns ApiContract. The ApiContract is compatible with + MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + ApiCreateOrUpdateParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns ApiContract. The ApiContract is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.ApiContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + parameters: _models.ApiUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Update Contract parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Update Contract parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Update Contract parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :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, + parameters: Union[_models.ApiUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: API Update Contract parameters. Is one of the following types: + ApiUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_revisions: Delete all revisions of the Api. Default value is None. + :paramtype delete_revisions: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_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, + etag=etag, + match_condition=match_condition, + delete_revisions=delete_revisions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.ApiContract"]: + """Lists all APIs 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword tags: Include tags in the response. Default value is None. + :paramtype tags: str + :keyword expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. + :paramtype expand_api_version_set: bool + :return: An iterator like instance of ApiContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_release_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_release_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: ApiReleaseContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_release_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + 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, + parameters: _models.ApiReleaseContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Release Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Release Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Release Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + parameters: Union[_models.ApiReleaseContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: API Release Update parameters. Is one of the following types: + ApiReleaseContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_release_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_release_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| notes | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiReleaseContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiReleaseContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_release_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiReleaseContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: OperationContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_operation_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + 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, + parameters: _models.OperationUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Operation Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Operation Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: API Operation Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + parameters: Union[_models.OperationUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: API Operation Update parameters. Is one of the following types: + OperationUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_operation_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword tags: Include tags in the response. Default value is None. + :paramtype tags: str + :return: An iterator like instance of OperationContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OperationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OperationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_operation_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OperationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class GraphQLApiResolverPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`graph_ql_api_resolver_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Get the policy configuration at the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the GraphQL API resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates policy configuration for the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_graph_ql_api_resolver_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + 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, + api_id: str, + resolver_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the policy configuration at the GraphQL Api Resolver. + + :param resource_group_name: The name of the resource group. The name is 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param policy_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_resolver( + self, resource_group_name: str, service_name: str, api_id: str, resolver_id: str, **kwargs: Any + ) -> ItemPaged["_models.PolicyContract"]: + """Get the list of policy configuration at the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :return: An iterator like instance of PolicyContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_graph_ql_api_resolver_policy_list_by_resolver_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_api_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + 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, + api_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any + ) -> _models.PolicyCollection: + """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 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: PolicyCollection. The PolicyCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + _request = build_api_policy_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Get the Global policy definition 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_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, policy_id: Union[str, _models.PolicyIdName], **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Global policy definition 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_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates the global policy 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_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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates the global policy 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_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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates the global policy 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_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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PolicyContract: + """Creates or updates the global policy 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_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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + 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_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the global policy 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_id: The identifier of the Policy. "policy" Required. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> ItemPaged["_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. + 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 PolicyContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_policy_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ProductPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_product_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + 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, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_product( + self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any + ) -> ItemPaged["_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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: An iterator like instance of PolicyContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_workspace_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_policy_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + 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], + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_policy_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, resource_group_name: str, service_name: str, workspace_id: str, **kwargs: Any + ) -> ItemPaged["_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 PolicyContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_operation_policy_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + 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], + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_operation_policy_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 PolicyContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_operation_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_policy_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + 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], + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_policy_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, resource_group_name: str, service_name: str, workspace_id: str, api_id: str, **kwargs: Any + ) -> ItemPaged["_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 PolicyContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + product_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_workspace_product_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_policy_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + 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], + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_policy_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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. The PolicyCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + _request = build_workspace_product_policy_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class TagOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tag` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_by_api( + self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Get tag associated with 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_get_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_state_by_api( + self, resource_group_name: str, service_name: str, api_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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_get_entity_state_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 assign_to_api( + self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Assign tag to 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_assign_to_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def detach_from_api( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any + ) -> None: + """Detach the tag from 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_detach_from_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.TagContract"]: + """Lists all Tags associated with 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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_by_operation( + self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Get tag associated with the 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_get_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_state_by_operation( + self, resource_group_name: str, service_name: str, api_id: str, operation_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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_get_entity_state_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 assign_to_operation( + self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Assign tag to the 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_assign_to_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def detach_from_operation( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any + ) -> None: + """Detach the tag from the 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_detach_from_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_operation( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.TagContract"]: + """Lists all Tags associated with the 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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_list_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_by_product( + self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Get tag associated with 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_get_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_state_by_product( + self, resource_group_name: str, service_name: str, product_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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_get_entity_state_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 assign_to_product( + self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any + ) -> _models.TagContract: + """Assign tag to 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_assign_to_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def detach_from_product( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any + ) -> None: + """Detach the tag from 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_detach_from_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.TagContract"]: + """Lists all Tags associated with 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, **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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_tag_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_state(self, resource_group_name: str, service_name: 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_get_entity_state_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: _models.TagCreateUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + tag_id: str, + parameters: Union[_models.TagCreateUpdateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Create parameters. Is one of the following types: TagCreateUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + 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, + tag_id: str, + parameters: _models.TagCreateUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + parameters: Union[_models.TagCreateUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :param parameters: Update parameters. Is one of the following types: TagCreateUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + 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, + tag_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific tag 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + Required. + :type tag_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + tag_id=tag_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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, + scope: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.TagContract"]: + """Lists a collection of tags 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. + :paramtype scope: str + :return: An iterator like instance of TagContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_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, + scope=scope, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagContract] = kwargs.pop("cls", None) + + _request = build_workspace_tag_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + tag_id: str, + parameters: _models.TagCreateUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: TagCreateUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + 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, + parameters: _models.TagCreateUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: TagContract. The TagContract is compatible with MutableMapping + :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, + parameters: Union[_models.TagCreateUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: TagCreateUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagCreateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagContract. The TagContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword scope: Scope like 'apis', 'products' or 'apis/{apiId}. Default value is None. + :paramtype scope: str + :return: An iterator like instance of TagContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_tag_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The SchemaContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SchemaContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SchemaContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + 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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_schema_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns SchemaContract. The SchemaContract is compatible + with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns SchemaContract. The SchemaContract is compatible + with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns SchemaContract. The SchemaContract is compatible + with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: SchemaContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns SchemaContract. The SchemaContract is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.SchemaContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword force: If true removes all references to the schema before deleting it. Default value + is None. + :paramtype force: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_schema_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, + etag=etag, + match_condition=match_condition, + force=force, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| contentType + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SchemaContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SchemaContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SchemaContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`diagnostic` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_diagnostic_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_diagnostic_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Create parameters. Is one of the following types: DiagnosticContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_diagnostic_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + etag: str, + match_condition: MatchConditions, + 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :param parameters: Diagnostic Update parameters. Is one of the following types: + DiagnosticContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_diagnostic_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + diagnostic_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. Required. + :type diagnostic_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_diagnostic_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.DiagnosticContract"]: + """Lists all diagnostics 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DiagnosticContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiagnosticContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DiagnosticContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_workspace_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: DiagnosticContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_diagnostic_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + parameters: _models.DiagnosticUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: Union[_models.DiagnosticUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Diagnostic Update parameters. Is one of the following types: + DiagnosticUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_diagnostic_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_diagnostic_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DiagnosticContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiagnosticContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DiagnosticContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: DiagnosticContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_diagnostic_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + parameters: _models.DiagnosticUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + parameters: Union[_models.DiagnosticUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Diagnostic Update parameters. Is one of the following types: + DiagnosticUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_diagnostic_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_diagnostic_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DiagnosticContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiagnosticContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_diagnostic_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DiagnosticContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class IssueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`issue` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, issue_id: str, **kwargs: Any) -> _models.IssueContract: + """Gets API Management issue 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IssueContract] = kwargs.pop("cls", None) + + _request = build_issue_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + ) -> ItemPaged["_models.IssueContract"]: + """Lists a collection of issues in the specified 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| state | filter | eq | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of IssueContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IssueContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_issue_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IssueContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ProductWikiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_wiki` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any) -> _models.WikiContract: + """Gets the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + _request = build_product_wiki_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_wiki_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: _models.WikiContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: Union[_models.WikiContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Create parameters. Is one of the following types: WikiContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_wiki_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + 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, + product_id: str, + parameters: _models.WikiUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: Union[_models.WikiUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Wiki Update parameters. Is one of the following types: WikiUpdateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_wiki_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + 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, + product_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified Wiki from 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_wiki_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + _request = build_workspace_api_version_set_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_version_set_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + version_set_id: str, + parameters: _models.ApiVersionSetContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + ApiVersionSetContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_version_set_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + 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, + parameters: _models.ApiVersionSetUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + parameters: Union[_models.ApiVersionSetUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: + ApiVersionSetUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_api_version_set_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_api_version_set_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiVersionSetContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiVersionSetContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_version_set_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiVersionSetContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + _request = build_workspace_backend_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_backend_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + backend_id: str, + parameters: _models.BackendContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: BackendContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_backend_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + 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, + parameters: _models.BackendUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + parameters: Union[_models.BackendUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: BackendUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_backend_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_backend_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of BackendContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.BackendContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.BackendContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_backend_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.BackendContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_workspace_certificate_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_certificate_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + certificate_id: str, + parameters: _models.CertificateCreateOrUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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 one of the following types: + CertificateCreateOrUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_certificate_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_certificate_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword is_key_vault_refresh_failed: When set to true, the response contains only certificates + entities which failed refresh. Default value is None. + :paramtype is_key_vault_refresh_failed: bool + :return: An iterator like instance of CertificateContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.CertificateContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CertificateContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_certificate_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CertificateContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type 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. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_workspace_certificate_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + _request = build_workspace_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + group_id: str, + parameters: _models.GroupCreateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: GroupCreateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_group_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + 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, + parameters: _models.GroupUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + parameters: Union[_models.GroupUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: GroupUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_group_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_group_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.GroupContract"]: + """Lists a collection of groups 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GroupContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GroupContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GroupContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + _request = build_workspace_logger_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_logger_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + logger_id: str, + parameters: _models.LoggerContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: LoggerContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_logger_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + 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, + parameters: _models.LoggerUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + parameters: Union[_models.LoggerUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: LoggerUpdateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_logger_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_logger_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.LoggerContract"]: + """Lists a collection of loggers 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of LoggerContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.LoggerContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LoggerContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_logger_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LoggerContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The NamedValueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NamedValueContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + named_value_id: str, + parameters: Union[_models.NamedValueCreateContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_named_value_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: NamedValueCreateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + parameters: Union[_models.NamedValueUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_named_value_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + parameters: _models.NamedValueUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, + parameters: Union[_models.NamedValueUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: + NamedValueUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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 = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.NamedValueContract"]: + """Lists a collection of named values 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword 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. + :paramtype is_key_vault_refresh_failed: str or + ~azure.mgmt.apimanagement.models.KeyVaultRefreshState + :return: An iterator like instance of NamedValueContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NamedValueContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NamedValueContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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. The NamedValueSecretContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamedValueSecretContract] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NamedValueSecretContract, response.json()) + + 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_workspace_named_value_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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 NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The NotificationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_workspace_notification_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NotificationContract, response.json()) + + 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], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: NotificationContract. The NotificationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_workspace_notification_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NotificationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of NotificationContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NotificationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NotificationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_notification_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NotificationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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 + :keyword format: Policy fragment content format. Known values are: "xml" and "rawxml". Default + value is None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :return: PolicyFragmentContract. The PolicyFragmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyFragmentContract] = kwargs.pop("cls", None) + + _request = build_workspace_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyFragmentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + id: str, + parameters: Union[_models.PolicyFragmentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_policy_fragment_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + PolicyFragmentContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.PolicyFragmentContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_policy_fragment_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + id=id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of PolicyFragmentContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyFragmentContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyFragmentContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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 + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: ResourceCollection. The ResourceCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ResourceCollection] = kwargs.pop("cls", None) + + _request = build_workspace_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class SignInSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`sign_in_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.PortalSigninSettings: + """Get Sign In Settings for the Portal. + + :param resource_group_name: The name of the resource group. The name 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: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalSigninSettings] = kwargs.pop("cls", None) + + _request = build_sign_in_settings_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSigninSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the SignInSettings. + + :param resource_group_name: The name of the resource group. The name 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: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sign_in_settings_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalSigninSettings, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSigninSettings: + """Create or Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSigninSettings: + """Create or Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSigninSettings: + """Create or Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalSigninSettings, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSigninSettings: + """Create or Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is one of the following types: + PortalSigninSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSigninSettings. The PortalSigninSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalSigninSettings] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sign_in_settings_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSigninSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalSigninSettings, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-In settings. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-In settings. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-In settings. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalSigninSettings, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Update Sign-In settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-In settings. Is one of the following types: + PortalSigninSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sign_in_settings_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class SignUpSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`sign_up_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.PortalSignupSettings: + """Get Sign Up Settings for the Portal. + + :param resource_group_name: The name of the resource group. The name 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: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalSignupSettings] = kwargs.pop("cls", None) + + _request = build_sign_up_settings_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSignupSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the SignUpSettings. + + :param resource_group_name: The name of the resource group. The name 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: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_sign_up_settings_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalSignupSettings, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSignupSettings: + """Create or Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSignupSettings: + """Create or Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSignupSettings: + """Create or Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalSignupSettings, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalSignupSettings: + """Create or Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is one of the following types: + PortalSignupSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalSignupSettings. The PortalSignupSettings is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalSignupSettings] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sign_up_settings_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSignupSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalSignupSettings, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-Up settings. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-Up settings. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-Up settings. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalSignupSettings, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Update Sign-Up settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Sign-Up settings. Is one of the following types: + PortalSignupSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_sign_up_settings_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class DelegationSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`delegation_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.PortalDelegationSettings: + """Get Delegation Settings for the Portal. + + :param resource_group_name: The name of the resource group. The name 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: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalDelegationSettings] = kwargs.pop("cls", None) + + _request = build_delegation_settings_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalDelegationSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the DelegationSettings. + + :param resource_group_name: The name of the resource group. The name 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: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_delegation_settings_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalDelegationSettings, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalDelegationSettings: + """Create or Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalDelegationSettings: + """Create or Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalDelegationSettings: + """Create or Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalDelegationSettings, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.PortalDelegationSettings: + """Create or Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is one of the following types: + PortalDelegationSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalDelegationSettings. The PortalDelegationSettings is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalDelegationSettings] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_delegation_settings_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalDelegationSettings, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + parameters: _models.PortalDelegationSettings, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Delegation settings. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Delegation settings. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Delegation settings. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.PortalDelegationSettings, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Update Delegation settings. + + :param resource_group_name: The name of the resource group. The name is 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: Update Delegation settings. Is one of the following types: + PortalDelegationSettings, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_delegation_settings_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, **kwargs: Any + ) -> _models.PortalSettingValidationKeyContract: + """Gets the secret validation key of the DelegationSettings. + + :param resource_group_name: The name of the resource group. The name 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: PortalSettingValidationKeyContract. The PortalSettingValidationKeyContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalSettingValidationKeyContract] = kwargs.pop("cls", None) + + _request = build_delegation_settings_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSettingValidationKeyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + _request = build_workspace_product_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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, **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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + product_id: str, + parameters: _models.ProductContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: ProductContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + 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, + parameters: _models.ProductUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + parameters: Union[_models.ProductUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Update parameters. Is one of the following types: ProductUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_subscriptions: Delete existing subscriptions associated with the product or + not. Default value is None. + :paramtype delete_subscriptions: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_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, + etag=etag, + match_condition=match_condition, + delete_subscriptions=delete_subscriptions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword 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. + :paramtype expand_groups: bool + :keyword tags: Products which are part of a specific tag. Default value is None. + :paramtype tags: str + :return: An iterator like instance of ProductContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_product_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The ProductApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductApiLinkContract, response.json()) + + 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. The ProductApiLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract. The ProductApiLinkContract is compatible with MutableMapping + :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. The ProductApiLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + ProductApiLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract or JSON or IO[bytes] + :return: ProductApiLinkContract. The ProductApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_api_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductApiLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductApiLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductApiLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductApiLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The ProductGroupLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductGroupLinkContract, response.json()) + + 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. The ProductGroupLinkContract is compatible with + MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract. The ProductGroupLinkContract is compatible with + MutableMapping + :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. The ProductGroupLinkContract is compatible with + MutableMapping + :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, JSON, 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 one of the following types: + ProductGroupLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract or JSON or + IO[bytes] + :return: ProductGroupLinkContract. The ProductGroupLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_product_group_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductGroupLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| groupId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductGroupLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductGroupLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductGroupLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The GlobalSchemaContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GlobalSchemaContract] = kwargs.pop("cls", None) + + _request = build_workspace_global_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GlobalSchemaContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_global_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_global_schema_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GlobalSchemaContract. The GlobalSchemaContract + is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GlobalSchemaContract. The GlobalSchemaContract + is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GlobalSchemaContract. The GlobalSchemaContract + is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + GlobalSchemaContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GlobalSchemaContract. The GlobalSchemaContract + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.GlobalSchemaContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_global_schema_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, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GlobalSchemaContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GlobalSchemaContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_global_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GlobalSchemaContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class UserSubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user_subscription` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, user_id: str, sid: str, **kwargs: Any + ) -> _models.SubscriptionContract: + """Gets the specified Subscription entity associated with a particular 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + _request = build_user_subscription_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + user_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.SubscriptionContract"]: + """Lists the collection of subscriptions of the specified 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 + :keyword 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 |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SubscriptionContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_user_subscription_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, 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. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @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, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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: JSON, + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: IO[bytes] + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + SubscriptionCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters or JSON or + IO[bytes] + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_subscription_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, + app_type=app_type, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + 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, + parameters: _models.SubscriptionUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :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, + parameters: Union[_models.SubscriptionUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Update parameters. Is one of the following types: + SubscriptionUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_subscription_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + notify=notify, + app_type=app_type, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + sid=sid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SubscriptionContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The SubscriptionKeysContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionKeysContract] = kwargs.pop("cls", None) + + _request = build_workspace_subscription_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionKeysContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The TagApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagApiLinkContract, response.json()) + + 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. The TagApiLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract. The TagApiLinkContract is compatible with MutableMapping + :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. The TagApiLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + TagApiLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract or JSON or IO[bytes] + :return: TagApiLinkContract. The TagApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_api_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagApiLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagApiLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagApiLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagApiLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The TagOperationLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagOperationLinkContract, response.json()) + + 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. The TagOperationLinkContract is compatible with + MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract. The TagOperationLinkContract is compatible with + MutableMapping + :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. The TagOperationLinkContract is compatible with + MutableMapping + :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, JSON, 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 one of the following types: + TagOperationLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract or JSON or + IO[bytes] + :return: TagOperationLinkContract. The TagOperationLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_operation_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagOperationLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| operationId + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagOperationLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagOperationLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagOperationLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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. The TagProductLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + _request = build_workspace_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagProductLinkContract, response.json()) + + 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. The TagProductLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract. The TagProductLinkContract is compatible with MutableMapping + :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. The TagProductLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + TagProductLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract or JSON or IO[bytes] + :return: TagProductLinkContract. The TagProductLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_tag_product_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagProductLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| productId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagProductLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagProductLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagProductLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiManagementOperationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]: + """Lists all of the available REST API operations of the Microsoft.ApiManagement provider. + + :return: An iterator like instance of Operation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_operations_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Operation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The ApiManagementGatewayResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementGatewayResource] = kwargs.pop("cls", None) + + _request = build_api_gateway_get_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementGatewayResource, response.json()) + + 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, + parameters: Union[_models.ApiManagementGatewayResource, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_gateway_create_or_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + 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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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, JSON, 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 one of the following types: ApiManagementGatewayResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayResource or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementGatewayResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_gateway_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :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, JSON, 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 one of the following types: ApiManagementGatewayUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayUpdateParameters or JSON + or IO[bytes] + :return: An instance of LROPoller that returns ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementGatewayResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 _delete_initial(self, resource_group_name: str, gateway_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_gateway_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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.iter_bytes() if _decompress else response.iter_raw() + + 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 ApiManagementGatewayResource. The + ApiManagementGatewayResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = _deserialize(_models.ApiManagementGatewayResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) -> ItemPaged["_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 ApiManagementGatewayResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementGatewayResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_gateway_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementGatewayResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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) -> ItemPaged["_models.ApiManagementGatewayResource"]: + """List all API Management gateways within a subscription. + + :return: An iterator like instance of ApiManagementGatewayResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementGatewayResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_gateway_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementGatewayResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_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 GatewayResourceSkuResult + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayResourceSkuResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayResourceSkuResult]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_gateway_skus_list_available_skus_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayResourceSkuResult], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: 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 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. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + _request = build_api_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + api_id: str, + parameters: _models.ApiCreateOrUpdateParameter, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.ApiContract]: + """Creates new or updates existing 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 parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns ApiContract. The ApiContract is compatible with + MutableMapping + :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, + api_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.ApiContract]: + """Creates new or updates existing 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 parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns ApiContract. The ApiContract is compatible with + MutableMapping + :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, + api_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.ApiContract]: + """Creates new or updates existing 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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns ApiContract. The ApiContract is compatible with + MutableMapping + :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, + api_id: str, + parameters: Union[_models.ApiCreateOrUpdateParameter, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.ApiContract]: + """Creates new or updates existing 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 parameters: Create or update parameters. Is one of the following types: + ApiCreateOrUpdateParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdateParameter or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns ApiContract. The ApiContract is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + api_id=api_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.ApiContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + api_id: str, + parameters: _models.ApiUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates 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 parameters: API Update Contract parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates 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 parameters: API Update Contract parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Updates 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 parameters: API Update Contract parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: Union[_models.ApiUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.ApiContract: + """Updates 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 parameters: API Update Contract parameters. Is one of the following types: + ApiUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + etag: str, + match_condition: MatchConditions, + delete_revisions: Optional[bool] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + delete_revisions=delete_revisions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + service_name: str, + api_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_revisions: Delete all revisions of the Api. Default value is None. + :paramtype delete_revisions: bool + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + delete_revisions=delete_revisions, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_service( + self, + resource_group_name: str, + service_name: 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 + ) -> ItemPaged["_models.ApiContract"]: + """Lists all APIs 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword tags: Include tags in the response. Default value is None. + :paramtype tags: str + :keyword expand_api_version_set: Include full ApiVersionSet resource in response. Default value + is None. + :paramtype expand_api_version_set: bool + :return: An iterator like instance of ApiContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_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, + tags=tags, + expand_api_version_set=expand_api_version_set, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_tags( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_apis: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.TagResourceContract"]: + """Lists a collection of apis associated with tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword 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 + |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| path | 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 |
| isCurrent | filter | eq | |
. Default value is + None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword include_not_tagged_apis: Include not tagged APIs. Default value is None. + :paramtype include_not_tagged_apis: bool + :return: An iterator like instance of TagResourceContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagResourceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_list_by_tags_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + include_not_tagged_apis=include_not_tagged_apis, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagResourceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_revision` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiRevision + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiRevisionContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiRevisionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_revision_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiRevisionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_product` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_apis( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.ProductContract"]: + """Lists all Products, which the API is part of. + + :param resource_group_name: The name of the resource group. The name is 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_product_list_by_apis_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class OperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`operation` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_tags( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_operations: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.TagResourceContract"]: + """Lists a collection of operations associated with tags. + + :param resource_group_name: The name of the resource group. The name is 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 + :keyword 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 + |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| method | 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword include_not_tagged_operations: Include not tagged Operations. Default value is None. + :paramtype include_not_tagged_operations: bool + :return: An iterator like instance of TagResourceContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagResourceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_operation_list_by_tags_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + include_not_tagged_operations=include_not_tagged_operations, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagResourceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiRevision + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiRevisionContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiRevisionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_api_revision_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiRevisionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiManagementServiceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_service` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, **kwargs: Any) -> _models.ApiManagementServiceResource: + """Gets an API Management service 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 + :return: ApiManagementServiceResource. The ApiManagementServiceResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementServiceResource] = kwargs.pop("cls", None) + + _request = build_api_management_service_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceResource, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + parameters: _models.ApiManagementServiceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. + Required. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceResource, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Creates or updates an API Management service. 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: Parameters supplied to the CreateOrUpdate API Management service operation. + Is one of the following types: ApiManagementServiceResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource or JSON or + IO[bytes] + :return: An instance of LROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + parameters: _models.ApiManagementServiceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. + Required. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceUpdateParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Updates an existing 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 parameters: Parameters supplied to the CreateOrUpdate API Management service operation. + Is one of the following types: ApiManagementServiceUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters or JSON + or IO[bytes] + :return: An instance of LROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_management_service_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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, 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, service_name: str, **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Deletes an existing 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 + :return: An instance of LROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + 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, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementServiceResource]( + 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 + ) -> ItemPaged["_models.ApiManagementServiceResource"]: + """List all API Management services 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 ApiManagementServiceResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_service_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementServiceResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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) -> ItemPaged["_models.ApiManagementServiceResource"]: + """Lists all API Management services within an Azure subscription. + + :return: An iterator like instance of ApiManagementServiceResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementServiceResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_service_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementServiceResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _restore_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_restore_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_restore( + self, + resource_group_name: str, + service_name: str, + parameters: _models.ApiManagementServiceBackupRestoreParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup + operation. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup + operation. Required. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup + 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a 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: Parameters supplied to the Restore API Management service from backup + operation. Is one of the following types: ApiManagementServiceBackupRestoreParameters, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + or JSON or IO[bytes] + :return: An instance of LROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._restore_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _backup_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_backup_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_backup( + self, + resource_group_name: str, + service_name: str, + parameters: _models.ApiManagementServiceBackupRestoreParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_backup( + self, + resource_group_name: str, + service_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Required. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_backup( + self, + resource_group_name: str, + service_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_backup( + self, + resource_group_name: str, + service_name: str, + parameters: Union[_models.ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Creates a backup of the API Management service to the given Azure Storage Account. 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: Parameters supplied to the ApiManagementService_Backup operation. Is one of + the following types: ApiManagementServiceBackupRestoreParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters + or JSON or IO[bytes] + :return: An instance of LROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._backup_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _migrate_to_stv2_initial( + self, + resource_group_name: str, + service_name: str, + parameters: Optional[Union[_models.MigrateToStv2Contract, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_api_management_service_migrate_to_stv2_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :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[JSON] = 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: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :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, + parameters: Optional[Union[_models.MigrateToStv2Contract, JSON, 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 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. Is one of the following + types: MigrateToStv2Contract, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.MigrateToStv2Contract or JSON or IO[bytes] + :return: An instance of LROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._migrate_to_stv2_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get_sso_token( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.ApiManagementServiceGetSsoTokenResult: + """Gets the Single-Sign-On token for the API Management Service which is 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 + :return: ApiManagementServiceGetSsoTokenResult. The ApiManagementServiceGetSsoTokenResult is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementServiceGetSsoTokenResult] = kwargs.pop("cls", None) + + _request = build_api_management_service_get_sso_token_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementServiceGetSsoTokenResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _apply_network_configuration_updates_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[ + Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, JSON, IO[bytes]] + ] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_api_management_service_apply_network_configuration_updates_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_apply_network_configuration_updates( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[_models.ApiManagementServiceApplyNetworkConfigurationParameters] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + DNS changes. + + :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the + parameters are empty, all the regions in which the Api Management service is deployed will be + updated sequentially without incurring downtime in the region. Default value is None. + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_apply_network_configuration_updates( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + DNS changes. + + :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the + parameters are empty, all the regions in which the Api Management service is deployed will be + updated sequentially without incurring downtime in the region. Default value is None. + :type parameters: JSON + :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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_apply_network_configuration_updates( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + DNS changes. + + :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the + parameters are empty, all the regions in which the Api Management service is deployed will be + updated sequentially without incurring downtime in the region. 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 ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_apply_network_configuration_updates( # pylint: disable=name-too-long + self, + resource_group_name: str, + service_name: str, + parameters: Optional[ + Union[_models.ApiManagementServiceApplyNetworkConfigurationParameters, JSON, IO[bytes]] + ] = None, + **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + DNS changes. + + :param resource_group_name: The name of the resource group. The name is 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: Parameters supplied to the Apply Network Configuration operation. If the + parameters are empty, all the regions in which the Api Management service is deployed will be + updated sequentially without incurring downtime in the region. Is one of the following types: + ApiManagementServiceApplyNetworkConfigurationParameters, JSON, IO[bytes] Default value is None. + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceApplyNetworkConfigurationParameters or + JSON or IO[bytes] + :return: An instance of LROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._apply_network_configuration_updates_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _refresh_hostnames_initial(self, resource_group_name: str, service_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_management_service_refresh_hostnames_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_refresh_hostnames( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> LROPoller[_models.ApiManagementServiceResource]: + """Force Refresh the SSL certificate attached to the Custom Hostnames configured using secret from + KeyVault on 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 + :return: An instance of LROPoller that returns ApiManagementServiceResource. The + ApiManagementServiceResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._refresh_hostnames_initial( + resource_group_name=resource_group_name, + service_name=service_name, + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ApiManagementServiceResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ApiManagementServiceResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ApiManagementServiceResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @overload + def check_name_availability( + self, + parameters: _models.ApiManagementServiceCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiManagementServiceNameAvailabilityResult: + """Checks availability and correctness of a name for an API Management service. + + :param parameters: The request body. Required. + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiManagementServiceNameAvailabilityResult. The + ApiManagementServiceNameAvailabilityResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ApiManagementServiceNameAvailabilityResult: + """Checks availability and correctness of a name for an API Management service. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiManagementServiceNameAvailabilityResult. The + ApiManagementServiceNameAvailabilityResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ApiManagementServiceNameAvailabilityResult: + """Checks availability and correctness of a name for an API Management service. + + :param parameters: The request body. 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: ApiManagementServiceNameAvailabilityResult. The + ApiManagementServiceNameAvailabilityResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + parameters: Union[_models.ApiManagementServiceCheckNameAvailabilityParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ApiManagementServiceNameAvailabilityResult: + """Checks availability and correctness of a name for an API Management service. + + :param parameters: The request body. Is one of the following types: + ApiManagementServiceCheckNameAvailabilityParameters, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.apimanagement.models.ApiManagementServiceCheckNameAvailabilityParameters or JSON or + IO[bytes] + :return: ApiManagementServiceNameAvailabilityResult. The + ApiManagementServiceNameAvailabilityResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ApiManagementServiceNameAvailabilityResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_service_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementServiceNameAvailabilityResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_domain_ownership_identifier( + self, **kwargs: Any + ) -> _models.ApiManagementServiceGetDomainOwnershipIdentifierResult: + """Get the custom domain ownership identifier for an API Management service. + + :return: ApiManagementServiceGetDomainOwnershipIdentifierResult. The + ApiManagementServiceGetDomainOwnershipIdentifierResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetDomainOwnershipIdentifierResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementServiceGetDomainOwnershipIdentifierResult] = kwargs.pop("cls", None) + + _request = build_api_management_service_get_domain_ownership_identifier_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementServiceGetDomainOwnershipIdentifierResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_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 AllPoliciesContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AllPoliciesContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AllPoliciesContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_all_policies_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AllPoliciesContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiManagementServiceSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_service_skus` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_available_service_skus( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> ItemPaged["_models.ResourceSkuResult"]: + """Gets all available SKU for a given 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 + :return: An iterator like instance of ResourceSkuResult + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResourceSkuResult]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_service_skus_list_available_service_skus_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResourceSkuResult], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class NetworkStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`network_status` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> List[_models.NetworkStatusContractByLocation]: + """Gets the Connectivity Status to the external resources on which the Api Management service + depends from inside the Cloud Service. This also returns the DNS Servers as visible to the + CloudService. + + :param resource_group_name: The name of the resource group. The name 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: list of NetworkStatusContractByLocation + :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NetworkStatusContractByLocation]] = kwargs.pop("cls", None) + + _request = build_network_status_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(List[_models.NetworkStatusContractByLocation], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_location( + self, resource_group_name: str, service_name: str, location_name: str, **kwargs: Any + ) -> _models.NetworkStatusContract: + """Gets the Connectivity Status to the external resources on which the Api Management service + depends from inside the Cloud Service. This also returns the DNS Servers as visible to the + CloudService. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param location_name: Location in which the API Management service is deployed. This is one of + the Azure Regions like West US, East US, South Central US. Required. + :type location_name: str + :return: NetworkStatusContract. The NetworkStatusContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NetworkStatusContract] = kwargs.pop("cls", None) + + _request = build_network_status_list_by_location_request( + resource_group_name=resource_group_name, + service_name=service_name, + location_name=location_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NetworkStatusContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class OutboundNetworkDependenciesEndpointsOperations: # 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:`outbound_network_dependencies_endpoints` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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.OutboundEnvironmentEndpointList: + """Gets the network endpoints of all outbound dependencies of a ApiManagement 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: OutboundEnvironmentEndpointList. The OutboundEnvironmentEndpointList is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpointList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OutboundEnvironmentEndpointList] = kwargs.pop("cls", None) + + _request = build_outbound_network_dependencies_endpoints_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OutboundEnvironmentEndpointList, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PolicyDescriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`policy_description` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + scope: Optional[Union[str, _models.PolicyScopeContract]] = None, + **kwargs: Any + ) -> _models.PolicyDescriptionCollection: + """Lists all policy descriptions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword scope: Policy scope. Known values are: "Tenant", "Product", "Api", "Operation", and + "All". Default value is None. + :paramtype scope: str or ~azure.mgmt.apimanagement.models.PolicyScopeContract + :return: PolicyDescriptionCollection. The PolicyDescriptionCollection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyDescriptionCollection] = kwargs.pop("cls", None) + + _request = build_policy_description_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + scope=scope, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyDescriptionCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_policy_restriction_validations_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + 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")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.OperationResultContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + +class PortalSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`portal_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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.PortalSettingsCollection: + """Lists a collection of portalsettings 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 + :return: PortalSettingsCollection. The PortalSettingsCollection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalSettingsCollection] = kwargs.pop("cls", None) + + _request = build_portal_settings_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalSettingsCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ProductOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_tags( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_products: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.TagResourceContract"]: + """Lists a collection of products associated with tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword 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 | substringof, contains, startswith, endswith |
. + Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword include_not_tagged_products: Include not tagged Products. Default value is None. + :paramtype include_not_tagged_products: bool + :return: An iterator like instance of TagResourceContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagResourceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_list_by_tags_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + include_not_tagged_products=include_not_tagged_products, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagResourceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, **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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductContract] = kwargs.pop("cls", None) + + _request = build_product_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: _models.ProductContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :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, + product_id: str, + parameters: Union[_models.ProductContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: ProductContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + 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, + product_id: str, + parameters: _models.ProductUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: Union[_models.ProductUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param parameters: Update parameters. Is one of the following types: ProductUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ProductContract. The ProductContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductContract, response.json()) + + 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, + product_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_subscriptions: Delete existing subscriptions associated with the product or + not. Default value is None. + :paramtype delete_subscriptions: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + delete_subscriptions=delete_subscriptions, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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, + expand_groups: Optional[bool] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ProductContract"]: + """Lists a collection of products in the specified 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword 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. + :paramtype expand_groups: bool + :keyword tags: Products which are part of a specific tag. Default value is None. + :paramtype tags: str + :return: An iterator like instance of ProductContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_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, + expand_groups=expand_groups, + tags=tags, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class QuotaByCounterKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`quota_by_counter_keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, quota_counter_key: str, **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Lists a collection of current quota counter periods associated with the counter-key configured + in the policy on the specified service instance. The api does not support paging yet. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :return: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.QuotaCounterCollection] = kwargs.pop("cls", None) + + _request = build_quota_by_counter_keys_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaCounterCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + parameters: _models.QuotaCounterValueUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param parameters: The value of the quota counter to be applied to all quota counter periods. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param parameters: The value of the quota counter to be applied to all quota counter periods. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param parameters: The value of the quota counter to be applied to all quota counter periods. + 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: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + parameters: Union[_models.QuotaCounterValueUpdateContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.QuotaCounterCollection: + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param parameters: The value of the quota counter to be applied to all quota counter periods. + Is one of the following types: QuotaCounterValueUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or JSON or + IO[bytes] + :return: QuotaCounterCollection. The QuotaCounterCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QuotaCounterCollection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_quota_by_counter_keys_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaCounterCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class QuotaByPeriodKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`quota_by_period_keys` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, quota_counter_key: str, quota_period_key: str, **kwargs: Any + ) -> _models.QuotaCounterContract: + """Gets the value of the quota counter associated with the counter-key in the policy for the + specific period in 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :return: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.QuotaCounterContract] = kwargs.pop("cls", None) + + _request = build_quota_by_period_keys_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + quota_period_key=quota_period_key, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaCounterContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + parameters: _models.QuotaCounterValueUpdateContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterContract: + """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :param parameters: The value of the Quota counter to be applied on the specified period. + Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterContract: + """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :param parameters: The value of the Quota counter to be applied on the specified period. + Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QuotaCounterContract: + """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :param parameters: The value of the Quota counter to be applied on the specified period. + 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: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + parameters: Union[_models.QuotaCounterValueUpdateContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.QuotaCounterContract: + """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier. This is the result of expression + defined in ``counter-key`` attribute of the quota-by-key policy. For example, if you specify + ``counter-key="boo"`` in the policy, then it’s accessible by ``"boo"`` counter key. But if it’s + defined as ``counter-key="@("b"+"a")"`` then it will be accessible by ``"ba"`` key. Required. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. Required. + :type quota_period_key: str + :param parameters: The value of the Quota counter to be applied on the specified period. Is one + of the following types: QuotaCounterValueUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or JSON or + IO[bytes] + :return: QuotaCounterContract. The QuotaCounterContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.QuotaCounterContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_quota_by_period_keys_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + quota_counter_key=quota_counter_key, + quota_period_key=quota_period_key, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.QuotaCounterContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class RegionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`region` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.RegionContract"]: + """Lists all azure regions in which the service exists. + + :param resource_group_name: The name of the resource group. The name 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 RegionContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.RegionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RegionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_region_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RegionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ReportsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`reports` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ReportRecordContract"]: + """Lists report records by 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 + :keyword filter: The filter to apply on the operation. Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_user( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ReportRecordContract"]: + """Lists report records by 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| userId | + select, filter | eq | |
| apiRegion | filter | eq | |
| productId | filter | + eq | |
| subscriptionId | filter | eq | |
| apiId | filter | eq | | +
| operationId | filter | eq | |
| callCountSuccess | select, orderBy | | + |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, + orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_user_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_operation( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ReportRecordContract"]: + """Lists report records by API Operations. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | +
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| + operationId | select, filter | eq | |
| callCountSuccess | select, orderBy | | + |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, + orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_product( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ReportRecordContract"]: + """Lists report records by 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | select, filter | eq + | |
| subscriptionId | filter | eq | |
| callCountSuccess | select, orderBy | + | |
| callCountBlocked | select, orderBy | | |
| callCountFailed | + select, orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_product_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_geo( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.ReportRecordContract"]: + """Lists report records by geography. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| country | select | | |
| region | select | | + |
| zip | select | | |
| apiRegion | filter | eq | |
| userId | + filter | eq | |
| productId | filter | eq | |
| subscriptionId | filter | eq + | |
| apiId | filter | eq | |
| operationId | filter | eq | |
| + callCountSuccess | select | | |
| callCountBlocked | select | | |
| + callCountFailed | select | | |
| callCountOther | select | | |
| + bandwidth | select, orderBy | | |
| cacheHitsCount | select | | |
| + cacheMissCount | select | | |
| apiTimeAvg | select | | |
| + apiTimeMin | select | | |
| apiTimeMax | select | | |
| + serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| + serviceTimeMax | select | | |
. Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ReportRecordContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_geo_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_subscription( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ReportRecordContract"]: + """Lists report records by 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | select, filter | eq | |
| productId | select, + filter | eq | |
| subscriptionId | select, filter | eq | |
| callCountSuccess + | select, orderBy | | |
| callCountBlocked | select, orderBy | | |
| + callCountFailed | select, orderBy | | |
| callCountOther | select, orderBy | | + |
| callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | + | |
| cacheHitsCount | select | | |
| cacheMissCount | select | | + |
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_subscription_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_time( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + interval: datetime.timedelta, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ReportRecordContract"]: + """Lists report records by Time. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter, select | ge, le | |
| interval | select | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | +
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| + operationId | filter | eq | |
| callCountSuccess | select | | |
| + callCountBlocked | select | | |
| callCountFailed | select | | |
| + callCountOther | select | | |
| bandwidth | select, orderBy | | |
| + cacheHitsCount | select | | |
| cacheMissCount | select | | |
| + apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | + select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | + select | | |
| serviceTimeMax | select | | |
. Required. + :paramtype filter: str + :keyword interval: By time interval. Interval must be multiple of 15 minutes and may not be + zero. The value should be in ISO 8601 format + (`http://en.wikipedia.org/wiki/ISO_8601#Durations).This + `_ code can be used to convert TimeSpan + to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). + Required. + :paramtype interval: ~datetime.timedelta + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :return: An iterator like instance of ReportRecordContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_time_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + interval=interval, + top=top, + skip=skip, + orderby=orderby, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_request( + self, + resource_group_name: str, + service_name: str, + *, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.RequestReportRecordContract"]: + """Lists report records by Request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| apiId | filter | eq | |
| operationId | filter | eq | + |
| productId | filter | eq | |
| userId | filter | eq | |
| apiRegion | + filter | eq | |
| subscriptionId | filter | eq | |
. Required. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of RequestReportRecordContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.RequestReportRecordContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.RequestReportRecordContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_reports_list_by_request_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RequestReportRecordContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class TagResourceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tag_resource` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.TagResourceContract"]: + """Lists a collection of resources associated with tags. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| aid | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| path | 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 |
| method | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
| urlTemplate | 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 | |
| isCurrent + | filter | eq | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagResourceContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagResourceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_resource_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagResourceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiReleaseOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_release` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 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. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiReleaseContract] = kwargs.pop("cls", None) + + _request = build_api_release_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_release_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: _models.ApiReleaseContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :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, + api_id: str, + release_id: str, + parameters: Union[_models.ApiReleaseContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: ApiReleaseContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_release_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + 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, + api_id: str, + release_id: str, + parameters: _models.ApiReleaseContract, + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Release Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Release Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Release Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + parameters: Union[_models.ApiReleaseContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 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: API Release Update parameters. Is one of the following types: + ApiReleaseContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiReleaseContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiReleaseContract. The ApiReleaseContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_release_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiReleaseContract, response.json()) + + 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, + api_id: str, + release_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_release_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + release_id=release_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| notes | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiReleaseContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiReleaseContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_release_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiReleaseContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiOperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_operation` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 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. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationContract] = kwargs.pop("cls", None) + + _request = build_api_operation_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_operation_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: _models.OperationContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :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, + api_id: str, + operation_id: str, + parameters: Union[_models.OperationContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: OperationContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_operation_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + 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, + api_id: str, + operation_id: str, + parameters: _models.OperationUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Operation Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Operation Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 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: API Operation Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: Union[_models.OperationUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 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: API Operation Update parameters. Is one of the following types: + OperationUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OperationUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OperationContract. The OperationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_operation_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationContract, response.json()) + + 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, + api_id: str, + operation_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_operation_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_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 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword tags: Include tags in the response. Default value is None. + :paramtype tags: str + :return: An iterator like instance of OperationContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OperationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OperationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_operation_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + tags=tags, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OperationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiOperationPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_operation_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + format: Optional[Union[str, _models.PolicyExportFormat]] = None, + **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 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 + :keyword format: Policy Export Format. Known values are: "xml" and "rawxml". Default value is + None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyExportFormat + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyContract] = kwargs.pop("cls", None) + + _request = build_api_operation_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_operation_policy_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: _models.PolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :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, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + parameters: Union[_models.PolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: PolicyContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyContract. The PolicyContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_operation_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyContract, response.json()) + + 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, + api_id: str, + operation_id: str, + policy_id: Union[str, _models.PolicyIdName], + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_operation_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + policy_id=policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_operation( + self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, **kwargs: Any + ) -> _models.PolicyCollection: + """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 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: PolicyCollection. The PolicyCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyCollection] = kwargs.pop("cls", None) + + _request = build_api_operation_policy_list_by_operation_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class GraphQLApiResolverOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`graph_ql_api_resolver` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, api_id: str, resolver_id: str, **kwargs: Any + ) -> _models.ResolverContract: + """Gets the details of the GraphQL API Resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ResolverContract] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResolverContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, resolver_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the GraphQL API resolver 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: _models.ResolverContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ResolverContract: + """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ResolverContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ResolverContract: + """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ResolverContract: + """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: Union[_models.ResolverContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ResolverContract: + """Creates a new resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: Create parameters. Is one of the following types: ResolverContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ResolverContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResolverContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_graph_ql_api_resolver_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResolverContract, response.json()) + + 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, + api_id: str, + resolver_id: str, + parameters: _models.ResolverUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResolverContract: + """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: GraphQL API Resolver Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ResolverUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResolverContract: + """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: GraphQL API Resolver Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResolverContract: + """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: GraphQL API Resolver Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + resolver_id: str, + parameters: Union[_models.ResolverUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.ResolverContract: + """Updates the details of the resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :param parameters: GraphQL API Resolver Update parameters. Is one of the following types: + ResolverUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ResolverUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ResolverContract. The ResolverContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResolverContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResolverContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_graph_ql_api_resolver_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResolverContract, response.json()) + + 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, + api_id: str, + resolver_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified resolver in the GraphQL 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 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 resolver_id: Resolver identifier within a GraphQL API. Must be unique in the current API + Management service instance. Required. + :type resolver_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_graph_ql_api_resolver_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + resolver_id=resolver_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.ResolverContract"]: + """Lists a collection of the resolvers for the specified GraphQL 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 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 + :keyword 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 |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ResolverContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ResolverContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ResolverContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_graph_ql_api_resolver_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ResolverContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_schema` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 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. The SchemaContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SchemaContract] = kwargs.pop("cls", None) + + _request = build_api_schema_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SchemaContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_schema_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + parameters: Union[_models.SchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_schema_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + api_id: str, + schema_id: str, + parameters: _models.SchemaContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns SchemaContract. The SchemaContract is compatible + with MutableMapping + :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, + api_id: str, + schema_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns SchemaContract. The SchemaContract is compatible + with MutableMapping + :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, + api_id: str, + schema_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns SchemaContract. The SchemaContract is compatible + with MutableMapping + :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, + api_id: str, + schema_id: str, + parameters: Union[_models.SchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: SchemaContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns SchemaContract. The SchemaContract is compatible + with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + api_id=api_id, + schema_id=schema_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.SchemaContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + api_id: str, + schema_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword force: If true removes all references to the schema before deleting it. Default value + is None. + :paramtype force: bool + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_schema_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + force=force, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| contentType + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SchemaContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SchemaContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_schema_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SchemaContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiDiagnosticOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_diagnostic` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 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. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DiagnosticContract] = kwargs.pop("cls", None) + + _request = build_api_diagnostic_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_diagnostic_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :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, + api_id: str, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: DiagnosticContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_diagnostic_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + api_id: str, + diagnostic_id: str, + parameters: _models.DiagnosticContract, + *, + etag: str, + match_condition: MatchConditions, + 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 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: Diagnostic Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 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: Diagnostic Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 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: Diagnostic Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: Union[_models.DiagnosticContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 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: Diagnostic Update parameters. Is one of the following types: + DiagnosticContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DiagnosticContract. The DiagnosticContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_diagnostic_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DiagnosticContract, response.json()) + + 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, + api_id: str, + diagnostic_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_diagnostic_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + diagnostic_id=diagnostic_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DiagnosticContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DiagnosticContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_diagnostic_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DiagnosticContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiIssueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_issue` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + *, + expand_comments_attachments: Optional[bool] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Gets the details of the Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :keyword expand_comments_attachments: Expand the comment attachments. Default value is None. + :paramtype expand_comments_attachments: bool + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IssueContract] = kwargs.pop("cls", None) + + _request = build_api_issue_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + expand_comments_attachments=expand_comments_attachments, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, issue_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: _models.IssueContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: Union[_models.IssueContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueContract: + """Creates a new Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Create parameters. Is one of the following types: IssueContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IssueContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_issue_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueContract, response.json()) + + 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, + api_id: str, + issue_id: str, + parameters: _models.IssueUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IssueContract: + """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IssueContract: + """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IssueContract: + """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: Union[_models.IssueUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.IssueContract: + """Updates an existing issue for 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param parameters: Update parameters. Is one of the following types: IssueUpdateContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueContract. The IssueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IssueContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_issue_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueContract, response.json()) + + 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, + api_id: str, + issue_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified Issue 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + expand_comments_attachments: Optional[bool] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.IssueContract"]: + """Lists all issues associated with 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | + filter | eq | |
. Default value is None. + :paramtype filter: str + :keyword expand_comments_attachments: Expand the comment attachments. Default value is None. + :paramtype expand_comments_attachments: bool + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of IssueContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IssueContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_issue_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + expand_comments_attachments=expand_comments_attachments, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IssueContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiIssueCommentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_issue_comment` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, api_id: str, issue_id: str, comment_id: str, **kwargs: Any + ) -> _models.IssueCommentContract: + """Gets the details of the issue Comment 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IssueCommentContract] = kwargs.pop("cls", None) + + _request = build_api_issue_comment_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueCommentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, issue_id: str, comment_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the issue Comment 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_comment_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: _models.IssueCommentContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueCommentContract: + """Creates a new Comment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueCommentContract: + """Creates a new Comment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueCommentContract: + """Creates a new Comment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: Union[_models.IssueCommentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueCommentContract: + """Creates a new Comment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :param parameters: Create parameters. Is one of the following types: IssueCommentContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueCommentContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueCommentContract. The IssueCommentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IssueCommentContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_issue_comment_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueCommentContract, response.json()) + + 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, + api_id: str, + issue_id: str, + comment_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified comment from an Issue. + + :param resource_group_name: The name of the resource group. The name is 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + Required. + :type comment_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_comment_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + comment_id=comment_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.IssueCommentContract"]: + """Lists all comments for the Issue associated with 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of IssueCommentContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueCommentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IssueCommentContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_issue_comment_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IssueCommentContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiIssueAttachmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_issue_attachment` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, api_id: str, issue_id: str, attachment_id: str, **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Gets the details of the issue Attachment 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IssueAttachmentContract] = kwargs.pop("cls", None) + + _request = build_api_issue_attachment_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueAttachmentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, issue_id: str, attachment_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the issue Attachment 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_attachment_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: _models.IssueAttachmentContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Creates a new Attachment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Creates a new Attachment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Creates a new Attachment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: Union[_models.IssueAttachmentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IssueAttachmentContract: + """Creates a new Attachment for the Issue in 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :param parameters: Create parameters. Is one of the following types: IssueAttachmentContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IssueAttachmentContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IssueAttachmentContract. The IssueAttachmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IssueAttachmentContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_issue_attachment_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IssueAttachmentContract, response.json()) + + 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, + api_id: str, + issue_id: str, + attachment_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified comment from an Issue. + + :param resource_group_name: The name of the resource group. The name is 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. Required. + :type attachment_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_issue_attachment_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + attachment_id=attachment_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.IssueAttachmentContract"]: + """Lists all attachments for the Issue associated with 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 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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. Required. + :type issue_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of IssueAttachmentContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IssueAttachmentContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_issue_attachment_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + issue_id=issue_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IssueAttachmentContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiTagDescriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_tag_description` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, api_id: str, tag_description_id: str, **kwargs: Any + ) -> _models.TagDescriptionContract: + """Get Tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagDescriptionContract] = kwargs.pop("cls", None) + + _request = build_api_tag_description_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagDescriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, tag_description_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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_tag_description_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: _models.TagDescriptionCreateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.TagDescriptionContract: + """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.TagDescriptionContract: + """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.TagDescriptionContract: + """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: Union[_models.TagDescriptionCreateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.TagDescriptionContract: + """Create/Update tag description in scope of 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :param parameters: Create parameters. Is one of the following types: + TagDescriptionCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagDescriptionCreateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: TagDescriptionContract. The TagDescriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TagDescriptionContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_tag_description_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagDescriptionContract, response.json()) + + 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, + api_id: str, + tag_description_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Delete tag description 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 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 tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. Required. + :type tag_description_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_tag_description_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tag_description_id=tag_description_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.TagDescriptionContract"]: + """Lists all Tags descriptions in scope of API. Model similar to swagger - tagDescription is + defined on API level but tag may be assigned to the Operations. + + :param resource_group_name: The name of the resource group. The name is 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagDescriptionContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagDescriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_tag_description_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagDescriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiWikiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_wiki` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any) -> _models.WikiContract: + """Gets the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + _request = build_api_wiki_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, api_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_wiki_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: _models.WikiContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: Union[_models.WikiContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.WikiContract: + """Creates a new Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Create parameters. Is one of the following types: WikiContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_wiki_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + 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, + api_id: str, + parameters: _models.WikiUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Wiki Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: Union[_models.WikiUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.WikiContract: + """Updates the details of the Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Wiki Update parameters. Is one of the following types: WikiUpdateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WikiContract. The WikiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WikiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.WikiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_wiki_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WikiContract, response.json()) + + 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, + api_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified Wiki 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_wiki_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ApiWikisOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_wikis` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.WikiContract"]: + """Gets the wikis 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | eq | contains |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of WikiContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.WikiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WikiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_wikis_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WikiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ProductWikisOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_wikis` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + 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 + ) -> ItemPaged["_models.WikiContract"]: + """Gets the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | eq | contains |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of WikiContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.WikiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WikiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_wikis_list_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WikiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiToolOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_tool` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, api_id: str, tool_id: str, **kwargs: Any + ) -> _models.ToolContract: + """Gets the details of the API Tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ToolContract] = kwargs.pop("cls", None) + + _request = build_api_tool_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, api_id: str, tool_id: str, **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the API tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_tool_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: _models.ToolContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Creates a new tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ToolContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Creates a new tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Creates a new tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: Create 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: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: Union[_models.ToolContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ToolContract: + """Creates a new tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: Create parameters. Is one of the following types: ToolContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ToolContract or JSON or IO[bytes] + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ToolContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_tool_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolContract, response.json()) + + 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, + api_id: str, + tool_id: str, + parameters: _models.ToolContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Updates the details of the tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: API Tool Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ToolContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Updates the details of the tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: API Tool Update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ToolContract: + """Updates the details of the tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: API Tool 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: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tool_id: str, + parameters: Union[_models.ToolContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ToolContract: + """Updates the details of the tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :param parameters: API Tool Update parameters. Is one of the following types: ToolContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ToolContract or JSON or IO[bytes] + :return: ToolContract. The ToolContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ToolContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ToolContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_tool_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolContract, response.json()) + + 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, api_id: str, tool_id: str, **kwargs: Any + ) -> None: + """Deletes the specified tool 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 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 tool_id: Tool identifier within an API. Must be unique in the current API Management + service instance. Required. + :type tool_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_tool_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + tool_id=tool_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.ToolContract"]: + """Lists a collection of the MCP tools 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 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 + :keyword 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 + |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ToolContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ToolContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ToolContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_tool_list_by_api_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ToolContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiVersionSetOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_version_set` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 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. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiVersionSetContract] = kwargs.pop("cls", None) + + _request = build_api_version_set_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_version_set_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: _models.ApiVersionSetContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :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, + version_set_id: str, + parameters: Union[_models.ApiVersionSetContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: + ApiVersionSetContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_version_set_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + 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, + version_set_id: str, + parameters: _models.ApiVersionSetUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 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: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 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: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 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: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: Union[_models.ApiVersionSetUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 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: Update parameters. Is one of the following types: + ApiVersionSetUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ApiVersionSetContract. The ApiVersionSetContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_version_set_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiVersionSetContract, response.json()) + + 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, + version_set_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. Required. + :type version_set_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_api_version_set_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + version_set_id=version_set_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.ApiVersionSetContract"]: + """Lists a collection of API Version Sets in the specified 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiVersionSetContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiVersionSetContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_version_set_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiVersionSetContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AuthorizationProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, authorization_provider_id: str, **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Gets the details of the authorization provider 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 authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationProviderContract] = kwargs.pop("cls", None) + + _request = build_authorization_provider_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationProviderContract, response.json()) + + 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, + authorization_provider_id: str, + parameters: _models.AuthorizationProviderContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + parameters: Union[_models.AuthorizationProviderContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Creates or updates authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param parameters: Create parameters. Is one of the following types: + AuthorizationProviderContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_provider_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationProviderContract, response.json()) + + 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, + authorization_provider_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific authorization provider from 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 authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_provider_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.AuthorizationProviderContract"]: + """Lists a collection of authorization providers 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of AuthorizationProviderContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AuthorizationProviderContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_authorization_provider_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AuthorizationProviderContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def refresh_secret( + self, resource_group_name: str, service_name: str, authorization_provider_id: str, **kwargs: Any + ) -> _models.AuthorizationProviderContract: + """Refreshes the Key Vault reference secret for the specified authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :return: AuthorizationProviderContract. The AuthorizationProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationProviderContract] = kwargs.pop("cls", None) + + _request = build_authorization_provider_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationProviderContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class AuthorizationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Gets the details of the authorization 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 authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationContract] = kwargs.pop("cls", None) + + _request = build_authorization_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationContract, response.json()) + + 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, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: Union[_models.AuthorizationContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationContract: + """Creates or updates authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Is one of the following types: AuthorizationContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationContract. The AuthorizationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationContract, response.json()) + + 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, + authorization_provider_id: str, + authorization_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific Authorization from the Authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_authorization_provider( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.AuthorizationContract"]: + """Lists a collection of authorization providers defined within a authorization provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of AuthorizationContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AuthorizationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_authorization_list_by_authorization_provider_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AuthorizationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def confirm_consent_code( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationConfirmConsentCodeRequestContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Confirm valid consent code to suppress Authorizations anti-phishing page. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: + ~azure.mgmt.apimanagement.models.AuthorizationConfirmConsentCodeRequestContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def confirm_consent_code( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Confirm valid consent code to suppress Authorizations anti-phishing page. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def confirm_consent_code( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Confirm valid consent code to suppress Authorizations anti-phishing page. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create 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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def confirm_consent_code( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: Union[_models.AuthorizationConfirmConsentCodeRequestContract, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Confirm valid consent code to suppress Authorizations anti-phishing page. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Is one of the following types: + AuthorizationConfirmConsentCodeRequestContract, JSON, IO[bytes] Required. + :type parameters: + ~azure.mgmt.apimanagement.models.AuthorizationConfirmConsentCodeRequestContract or JSON or + IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_confirm_consent_code_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + +class AuthorizationLoginLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization_login_links` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: _models.AuthorizationLoginRequestContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationLoginResponseContract. The AuthorizationLoginResponseContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationLoginResponseContract. The AuthorizationLoginResponseContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create 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: AuthorizationLoginResponseContract. The AuthorizationLoginResponseContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def post( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + parameters: Union[_models.AuthorizationLoginRequestContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.AuthorizationLoginResponseContract: + """Gets authorization login links. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param parameters: Create parameters. Is one of the following types: + AuthorizationLoginRequestContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationLoginRequestContract or JSON or + IO[bytes] + :return: AuthorizationLoginResponseContract. The AuthorizationLoginResponseContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationLoginResponseContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationLoginResponseContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_login_links_post_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationLoginResponseContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class AuthorizationAccessPolicyOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization_access_policy` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Gets the details of the authorization access 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 authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationAccessPolicyContract] = kwargs.pop("cls", None) + + _request = build_authorization_access_policy_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationAccessPolicyContract, response.json()) + + 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, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: _models.AuthorizationAccessPolicyContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + parameters: Union[_models.AuthorizationAccessPolicyContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationAccessPolicyContract: + """Creates or updates Authorization Access Policy. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :param parameters: Create parameters. Is one of the following types: + AuthorizationAccessPolicyContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationAccessPolicyContract. The AuthorizationAccessPolicyContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationAccessPolicyContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_access_policy_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationAccessPolicyContract, response.json()) + + 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, + authorization_provider_id: str, + authorization_id: str, + authorization_access_policy_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific access policy from the Authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :param authorization_access_policy_id: Identifier of the authorization access policy. Required. + :type authorization_access_policy_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_access_policy_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + authorization_access_policy_id=authorization_access_policy_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_authorization( + self, + resource_group_name: str, + service_name: str, + authorization_provider_id: str, + authorization_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.AuthorizationAccessPolicyContract"]: + """Lists a collection of authorization access policy defined within a authorization. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authorization_provider_id: Identifier of the authorization provider. Required. + :type authorization_provider_id: str + :param authorization_id: Identifier of the authorization. Required. + :type authorization_id: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of AuthorizationAccessPolicyContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationAccessPolicyContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AuthorizationAccessPolicyContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_authorization_access_policy_list_by_authorization_request( + resource_group_name=resource_group_name, + service_name=service_name, + authorization_provider_id=authorization_provider_id, + authorization_id=authorization_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AuthorizationAccessPolicyContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class AuthorizationServerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`authorization_server` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, authsid: str, **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Gets the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationServerContract] = kwargs.pop("cls", None) + + _request = build_authorization_server_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationServerContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, authsid: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the authorizationServer 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_server_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: _models.AuthorizationServerContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Creates new authorization server or updates an existing authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Creates new authorization server or updates an existing authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Creates new authorization server or updates an existing authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: Union[_models.AuthorizationServerContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Creates new authorization server or updates an existing authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: Create or update parameters. Is one of the following types: + AuthorizationServerContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationServerContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_server_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationServerContract, response.json()) + + 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, + authsid: str, + parameters: _models.AuthorizationServerUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: OAuth2 Server settings Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: OAuth2 Server settings Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: OAuth2 Server settings Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: Union[_models.AuthorizationServerUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.AuthorizationServerContract: + """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :param parameters: OAuth2 Server settings Update parameters. Is one of the following types: + AuthorizationServerUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AuthorizationServerContract. The AuthorizationServerContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AuthorizationServerContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_authorization_server_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationServerContract, response.json()) + + 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, + authsid: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific authorization server 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 authsid: Identifier of the authorization server. Required. + :type authsid: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_authorization_server_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.AuthorizationServerContract"]: + """Lists a collection of authorization servers 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of AuthorizationServerContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AuthorizationServerContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_authorization_server_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AuthorizationServerContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_secrets( + self, resource_group_name: str, service_name: str, authsid: str, **kwargs: Any + ) -> _models.AuthorizationServerSecretsContract: + """Gets the client secret details of the authorization server. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param authsid: Identifier of the authorization server. Required. + :type authsid: str + :return: AuthorizationServerSecretsContract. The AuthorizationServerSecretsContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AuthorizationServerSecretsContract] = kwargs.pop("cls", None) + + _request = build_authorization_server_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + authsid=authsid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AuthorizationServerSecretsContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class BackendOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`backend` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.BackendContract] = kwargs.pop("cls", None) + + _request = build_backend_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_backend_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: _models.BackendContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :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, + backend_id: str, + parameters: Union[_models.BackendContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: BackendContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backend_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + 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, + backend_id: str, + parameters: _models.BackendUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Union[_models.BackendUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :param parameters: Update parameters. Is one of the following types: BackendUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.BackendUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: BackendContract. The BackendContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_backend_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.BackendContract, response.json()) + + 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, + backend_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. Required. + :type backend_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_backend_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.BackendContract"]: + """Lists a collection of backends in the specified 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of BackendContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.BackendContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.BackendContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_backend_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.BackendContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def reconnect( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[_models.BackendReconnectContract] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Notifies the API Management gateway to create a new connection to the backend after the + specified timeout. If no timeout was specified, timeout of 2 minutes is used. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: 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: Reconnect request parameters. Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def reconnect( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Notifies the API Management gateway to create a new connection to the backend after the + specified timeout. If no timeout was specified, timeout of 2 minutes is used. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: 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: Reconnect request parameters. Default value is None. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def reconnect( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Notifies the API Management gateway to create a new connection to the backend after the + specified timeout. If no timeout was specified, timeout of 2 minutes is used. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: 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: Reconnect request parameters. 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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def reconnect( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: Optional[Union[_models.BackendReconnectContract, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> None: + """Notifies the API Management gateway to create a new connection to the backend after the + specified timeout. If no timeout was specified, timeout of 2 minutes is used. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: 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: Reconnect request parameters. Is one of the following types: + BackendReconnectContract, JSON, IO[bytes] Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.BackendReconnectContract or JSON or + IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_backend_reconnect_request( + resource_group_name=resource_group_name, + service_name=service_name, + backend_id=backend_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class CacheOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`cache` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, cache_id: str, **kwargs: Any) -> _models.CacheContract: + """Gets the details of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CacheContract] = kwargs.pop("cls", None) + + _request = build_cache_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CacheContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, cache_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_cache_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: _models.CacheContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CacheContract: + """Creates or updates an External Cache to be used in Api Management 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Create or Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CacheContract: + """Creates or updates an External Cache to be used in Api Management 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Create or Update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CacheContract: + """Creates or updates an External Cache to be used in Api Management 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: Union[_models.CacheContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CacheContract: + """Creates or updates an External Cache to be used in Api Management 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Create or Update parameters. Is one of the following types: CacheContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cache_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CacheContract, response.json()) + + 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, + cache_id: str, + parameters: _models.CacheUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CacheContract: + """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CacheContract: + """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CacheContract: + """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: Union[_models.CacheUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.CacheContract: + """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :param parameters: Update parameters. Is one of the following types: CacheUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.CacheUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CacheContract. The CacheContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CacheContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_cache_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CacheContract, response.json()) + + 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, + cache_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific Cache. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). Required. + :type cache_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_cache_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + cache_id=cache_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.CacheContract"]: + """Lists a collection of all external Caches in the specified 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 + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of CacheContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.CacheContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CacheContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_cache_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CacheContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class CertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`certificate` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_certificate_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_certificate_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_id: str, + parameters: _models.CertificateCreateOrUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :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, + certificate_id: str, + parameters: Union[_models.CertificateCreateOrUpdateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.CertificateContract: + """Creates or updates the certificate being used for authentication with the 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 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 one of the following types: + CertificateCreateOrUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.CertificateCreateOrUpdateParameters or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_certificate_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + 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, + certificate_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_certificate_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.CertificateContract"]: + """Lists a collection of all certificates in the specified 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword is_key_vault_refresh_failed: When set to true, the response contains only certificates + entities which failed refresh. Default value is None. + :paramtype is_key_vault_refresh_failed: bool + :return: An iterator like instance of CertificateContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.CertificateContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.CertificateContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_certificate_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, + is_key_vault_refresh_failed=is_key_vault_refresh_failed, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.CertificateContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def refresh_secret( + self, resource_group_name: str, service_name: str, certificate_id: str, **kwargs: Any + ) -> _models.CertificateContract: + """From KeyVault, Refresh the certificate being used for authentication with the 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: CertificateContract. The CertificateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.CertificateContract] = kwargs.pop("cls", None) + + _request = build_certificate_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CertificateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class ContentTypeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`content_type` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, content_type_id: str, **kwargs: Any + ) -> _models.ContentTypeContract: + """Gets the details of the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ContentTypeContract] = kwargs.pop("cls", None) + + _request = build_content_type_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContentTypeContract, response.json()) + + 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, + content_type_id: str, + parameters: _models.ContentTypeContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentTypeContract: + """Creates or updates the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Custom content types' identifiers need to start + with the ``c-`` prefix. Built-in content types can't be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentTypeContract: + """Creates or updates the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Custom content types' identifiers need to start + with the ``c-`` prefix. Built-in content types can't be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentTypeContract: + """Creates or updates the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Custom content types' identifiers need to start + with the ``c-`` prefix. Built-in content types can't be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + parameters: Union[_models.ContentTypeContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentTypeContract: + """Creates or updates the developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Custom content types' identifiers need to start + with the ``c-`` prefix. Built-in content types can't be modified. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param parameters: Create or update parameters. Is one of the following types: + ContentTypeContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ContentTypeContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentTypeContract. The ContentTypeContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ContentTypeContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_content_type_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContentTypeContract, response.json()) + + 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, + content_type_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Removes the specified developer portal's content type. Content types describe content items' + properties, validation rules, and constraints. Built-in content types (with identifiers + starting with the ``c-`` prefix) can't be removed. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_content_type_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> ItemPaged["_models.ContentTypeContract"]: + """Lists the developer portal's content types. Content types describe content items' properties, + validation rules, and constraints. + + :param resource_group_name: The name of the resource group. The name 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 ContentTypeContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentTypeContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ContentTypeContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_content_type_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ContentTypeContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ContentItemOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`content_item` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, content_type_id: str, content_item_id: str, **kwargs: Any + ) -> _models.ContentItemContract: + """Returns the developer portal's content item 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 content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ContentItemContract] = kwargs.pop("cls", None) + + _request = build_content_item_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContentItemContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, content_type_id: str, content_item_id: str, **kwargs: Any + ) -> bool: + """Returns the entity state (ETag) version of the developer portal's content item 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 content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_content_item_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + parameters: _models.ContentItemContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentItemContract: + """Creates a new developer portal's content item specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ContentItemContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentItemContract: + """Creates a new developer portal's content item specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :param parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentItemContract: + """Creates a new developer portal's content item specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + parameters: Union[_models.ContentItemContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.ContentItemContract: + """Creates a new developer portal's content item specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :param parameters: Create or update parameters. Is one of the following types: + ContentItemContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ContentItemContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: ContentItemContract. The ContentItemContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ContentItemContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ContentItemContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_content_item_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ContentItemContract, response.json()) + + 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, + content_type_id: str, + content_item_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Removes the specified developer portal's content item. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :param content_item_id: Content item identifier. Required. + :type content_item_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_content_item_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + content_item_id=content_item_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, content_type_id: str, **kwargs: Any + ) -> ItemPaged["_models.ContentItemContract"]: + """Lists developer portal's content items specified by the provided content type. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param content_type_id: Content type identifier. Required. + :type content_type_id: str + :return: An iterator like instance of ContentItemContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentItemContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ContentItemContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_content_item_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + content_type_id=content_type_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ContentItemContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DeletedServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`deleted_services` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_by_name(self, service_name: str, location: str, **kwargs: Any) -> _models.DeletedServiceContract: + """Get soft-deleted Api Management Service by name. + + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: DeletedServiceContract. The DeletedServiceContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DeletedServiceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedServiceContract] = kwargs.pop("cls", None) + + _request = build_deleted_services_get_by_name_request( + service_name=service_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DeletedServiceContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _purge_initial(self, service_name: str, location: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_deleted_services_purge_request( + service_name=service_name, + location=location, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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, 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_purge(self, service_name: str, location: str, **kwargs: Any) -> LROPoller[_models.DeletedServiceContract]: + """Purges Api Management Service (deletes it with no option to undelete). + + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param location: The name of the Azure region. Required. + :type location: str + :return: An instance of LROPoller that returns DeletedServiceContract. The + DeletedServiceContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DeletedServiceContract] = 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._purge_initial( + service_name=service_name, + location=location, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.DeletedServiceContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DeletedServiceContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DeletedServiceContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.DeletedServiceContract"]: + """Lists all soft-deleted services available for undelete for the given subscription. + + :return: An iterator like instance of DeletedServiceContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DeletedServiceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_deleted_services_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DeletedServiceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DocumentationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`documentation` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, documentation_id: str, **kwargs: Any + ) -> _models.DocumentationContract: + """Gets the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DocumentationContract] = kwargs.pop("cls", None) + + _request = build_documentation_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DocumentationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, documentation_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_documentation_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: _models.DocumentationContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.DocumentationContract: + """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DocumentationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.DocumentationContract: + """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.DocumentationContract: + """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: Union[_models.DocumentationContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.DocumentationContract: + """Creates a new Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Create parameters. Is one of the following types: DocumentationContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DocumentationContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DocumentationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_documentation_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DocumentationContract, response.json()) + + 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, + documentation_id: str, + parameters: _models.DocumentationUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DocumentationContract: + """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Documentation Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DocumentationUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DocumentationContract: + """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Documentation Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DocumentationContract: + """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Documentation Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + documentation_id: str, + parameters: Union[_models.DocumentationUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.DocumentationContract: + """Updates the details of the Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :param parameters: Documentation Update parameters. Is one of the following types: + DocumentationUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DocumentationUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: DocumentationContract. The DocumentationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.DocumentationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DocumentationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_documentation_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DocumentationContract, response.json()) + + 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, + documentation_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified Documentation 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 documentation_id: Documentation identifier. Must be unique in the current API Management + service instance. Required. + :type documentation_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_documentation_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + documentation_id=documentation_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.DocumentationContract"]: + """Lists all Documentations 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | eq | contains |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of DocumentationContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DocumentationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DocumentationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_documentation_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DocumentationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class EmailTemplateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`email_template` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Gets the details of the email template 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 template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.EmailTemplateContract] = kwargs.pop("cls", None) + + _request = build_email_template_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EmailTemplateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the email template 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 template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_email_template_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: _models.EmailTemplateUpdateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates an Email Template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: 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. + Known values are: "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Email Template update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates an Email Template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: 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. + Known values are: "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Email Template update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates an Email Template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: 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. + Known values are: "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Email Template 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: Union[_models.EmailTemplateUpdateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates an Email Template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: 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. + Known values are: "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Email Template update parameters. Is one of the following types: + EmailTemplateUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EmailTemplateContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_email_template_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EmailTemplateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: _models.EmailTemplateUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, _models.TemplateName], + parameters: Union[_models.EmailTemplateUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.EmailTemplateContract: + """Updates API Management email template. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Update parameters. Is one of the following types: + EmailTemplateUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: EmailTemplateContract. The EmailTemplateContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EmailTemplateContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_email_template_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EmailTemplateContract, response.json()) + + 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, + template_name: Union[str, _models.TemplateName], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Reset the Email Template to default template provided by 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 template_name: Email Template Name Identifier. Known values are: + "applicationApprovedNotificationMessage", "accountClosedDeveloper", + "quotaLimitApproachingDeveloperNotificationMessage", "newDeveloperNotificationMessage", + "emailChangeIdentityDefault", "inviteUserNotificationMessage", "newCommentNotificationMessage", + "confirmSignUpIdentityDefault", "newIssueNotificationMessage", + "purchaseDeveloperNotificationMessage", "passwordResetIdentityDefault", + "passwordResetByAdminNotificationMessage", "rejectDeveloperNotificationMessage", and + "requestDeveloperNotificationMessage". Required. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_email_template_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + template_name=template_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.EmailTemplateContract"]: + """Gets all email templates. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of EmailTemplateContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EmailTemplateContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_email_template_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.EmailTemplateContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The + ApiManagementGatewayConfigConnectionResource is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementGatewayConfigConnectionResource] = kwargs.pop("cls", None) + + _request = build_api_gateway_config_connection_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementGatewayConfigConnectionResource, response.json()) + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_gateway_config_connection_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + 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 ApiManagementGatewayConfigConnectionResource. + The ApiManagementGatewayConfigConnectionResource is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :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 ApiManagementGatewayConfigConnectionResource. + The ApiManagementGatewayConfigConnectionResource is compatible with MutableMapping + :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 ApiManagementGatewayConfigConnectionResource. + The ApiManagementGatewayConfigConnectionResource is compatible with MutableMapping + :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, JSON, 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 one of the following types: + ApiManagementGatewayConfigConnectionResource, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource + or JSON or IO[bytes] + :return: An instance of LROPoller that returns ApiManagementGatewayConfigConnectionResource. + The ApiManagementGatewayConfigConnectionResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.ApiManagementGatewayConfigConnectionResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_gateway_config_connection_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + config_connection_name=config_connection_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_gateway( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> ItemPaged["_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 ApiManagementGatewayConfigConnectionResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementGatewayConfigConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementGatewayConfigConnectionResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_gateway_config_connection_list_by_gateway_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementGatewayConfigConnectionResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiGatewayHostnameBindingOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_gateway_hostname_binding` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, gateway_name: str, hostname_binding_name: str, **kwargs: Any + ) -> _models.GatewayHostnameBindingResource: + """Gets an API Management gateway hostname binding 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :return: GatewayHostnameBindingResource. The GatewayHostnameBindingResource is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayHostnameBindingResource] = kwargs.pop("cls", None) + + _request = build_api_gateway_hostname_binding_get_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayHostnameBindingResource, response.json()) + + 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, + hostname_binding_name: str, + parameters: Union[_models.GatewayHostnameBindingResource, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_gateway_hostname_binding_create_or_update_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + gateway_name: str, + hostname_binding_name: str, + parameters: _models.GatewayHostnameBindingResource, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.GatewayHostnameBindingResource]: + """Creates or updates an API Management gateway hostname binding. 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway hostname + binding operation. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GatewayHostnameBindingResource. The + GatewayHostnameBindingResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.GatewayHostnameBindingResource]: + """Creates or updates an API Management gateway hostname binding. 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway hostname + binding operation. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GatewayHostnameBindingResource. The + GatewayHostnameBindingResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.GatewayHostnameBindingResource]: + """Creates or updates an API Management gateway hostname binding. 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway hostname + binding 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GatewayHostnameBindingResource. The + GatewayHostnameBindingResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + parameters: Union[_models.GatewayHostnameBindingResource, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.GatewayHostnameBindingResource]: + """Creates or updates an API Management gateway hostname binding. 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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management gateway hostname + binding operation. Is one of the following types: GatewayHostnameBindingResource, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GatewayHostnameBindingResource. The + GatewayHostnameBindingResource is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayHostnameBindingResource] = 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, + hostname_binding_name=hostname_binding_name, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = _deserialize(_models.GatewayHostnameBindingResource, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.GatewayHostnameBindingResource].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.GatewayHostnameBindingResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, + resource_group_name: str, + gateway_name: str, + hostname_binding_name: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_gateway_hostname_binding_delete_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + hostname_binding_name: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes an existing API Management gateway hostname binding. + + :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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + hostname_binding_name=hostname_binding_name, + etag=etag, + match_condition=match_condition, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_gateway( + self, resource_group_name: str, gateway_name: str, **kwargs: Any + ) -> ItemPaged["_models.GatewayHostnameBindingResource"]: + """List all API Management gateway hostname bindings 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 GatewayHostnameBindingResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameBindingResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayHostnameBindingResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_gateway_hostname_binding_list_by_gateway_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayHostnameBindingResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _refresh_secret_initial( + self, resource_group_name: str, gateway_name: str, hostname_binding_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_api_gateway_hostname_binding_refresh_secret_request( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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]: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, gateway_name: str, hostname_binding_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Refresh the secret for an API Management gateway hostname binding. + + :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 hostname_binding_name: Gateway hostname binding identifier. Must be unique in the scope + of parent Gateway entity. Required. + :type hostname_binding_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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._refresh_secret_initial( + resource_group_name=resource_group_name, + gateway_name=gateway_name, + hostname_binding_name=hostname_binding_name, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + +class GatewayOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`gateway` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, gateway_id: str, **kwargs: Any + ) -> _models.GatewayContract: + """Gets the details of the Gateway 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 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: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayContract] = kwargs.pop("cls", None) + + _request = build_gateway_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, gateway_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the Gateway 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 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: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayContract: + """Creates or updates a Gateway to be used in Api Management 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 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: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayContract: + """Creates or updates a Gateway to be used in Api Management 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 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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayContract: + """Creates or updates a Gateway to be used in Api Management 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 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: 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayContract: + """Creates or updates a Gateway to be used in Api Management 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 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: Is one of the following types: GatewayContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayContract, response.json()) + + 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, + gateway_id: str, + parameters: _models.GatewayContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayContract: + """Updates the details of the gateway 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 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: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayContract: + """Updates the details of the gateway 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 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: Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayContract: + """Updates the details of the gateway 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 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: Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.GatewayContract: + """Updates the details of the gateway 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 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: Is one of the following types: GatewayContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayContract. The GatewayContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayContract, response.json()) + + 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, + gateway_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.GatewayContract"]: + """Lists a collection of gateways registered with 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| region | + 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GatewayContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_gateway_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_keys( + self, resource_group_name: str, service_name: str, gateway_id: str, **kwargs: Any + ) -> _models.GatewayKeysContract: + """Retrieves gateway 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 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: GatewayKeysContract. The GatewayKeysContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayKeysContract] = kwargs.pop("cls", None) + + _request = build_gateway_list_keys_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayKeysContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def regenerate_key( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayKeyRegenerationRequestContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Regenerates specified gateway key invalidating any tokens created with it. + + :param resource_group_name: The name of the resource group. The name is 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: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Regenerates specified gateway key invalidating any tokens created with it. + + :param resource_group_name: The name of the resource group. The name is 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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Regenerates specified gateway key invalidating any tokens created with it. + + :param resource_group_name: The name of the resource group. The name is 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: 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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayKeyRegenerationRequestContract, JSON, IO[bytes]], + **kwargs: Any + ) -> None: + """Regenerates specified gateway key invalidating any tokens created with it. + + :param resource_group_name: The name of the resource group. The name is 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: Is one of the following types: GatewayKeyRegenerationRequestContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayKeyRegenerationRequestContract or + JSON or IO[bytes] + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_regenerate_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def generate_token( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: _models.GatewayTokenRequestContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayTokenContract: + """Gets the Shared Access Authorization Token for the 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: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayTokenContract. The GatewayTokenContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def generate_token( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayTokenContract: + """Gets the Shared Access Authorization Token for the 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: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayTokenContract. The GatewayTokenContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def generate_token( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.GatewayTokenContract: + """Gets the Shared Access Authorization Token for the 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: 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: GatewayTokenContract. The GatewayTokenContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def generate_token( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + parameters: Union[_models.GatewayTokenRequestContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.GatewayTokenContract: + """Gets the Shared Access Authorization Token for the 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: Is one of the following types: GatewayTokenRequestContract, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayTokenRequestContract or JSON or + IO[bytes] + :return: GatewayTokenContract. The GatewayTokenContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayTokenContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_generate_token_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayTokenContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The GatewayDebugCredentialsContract is compatible + with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GatewayDebugCredentialsContract. The GatewayDebugCredentialsContract is compatible + with MutableMapping + :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. The GatewayDebugCredentialsContract is compatible + with MutableMapping + :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, JSON, 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 one of the following types: + GatewayListDebugCredentialsContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListDebugCredentialsContract or JSON + or IO[bytes] + :return: GatewayDebugCredentialsContract. The GatewayDebugCredentialsContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayDebugCredentialsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_list_debug_credentials_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayDebugCredentialsContract, response.json()) + + 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 + :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: JSON, + *, + 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: JSON + :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 + :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 + :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, JSON, 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 one of the following types: + GatewayListTraceContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayListTraceContract or JSON or + IO[bytes] + :return: dict mapping str to any + :rtype: dict[str, any] + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_list_trace_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(dict[str, Any], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class GatewayApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`gateway_api` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + gateway_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.ApiContract"]: + """Lists a collection of the APIs associated with a 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_gateway_api_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, gateway_id: str, api_id: str, **kwargs: Any + ) -> bool: + """Checks that API entity specified by identifier is associated with the Gateway 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 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_api_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + parameters: Optional[_models.AssociationContract] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Default value is None. + :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + parameters: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Default value is None. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + parameters: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ApiContract: + """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: 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: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + parameters: Optional[Union[_models.AssociationContract, JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> _models.ApiContract: + """Adds an API to the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :param parameters: Is one of the following types: AssociationContract, JSON, IO[bytes] Default + value is None. + :type parameters: ~azure.mgmt.apimanagement.models.AssociationContract or JSON or IO[bytes] + :return: ApiContract. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + content_type = content_type if parameters else None + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" if parameters else None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + if parameters is not None: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + else: + _content = None + + _request = build_gateway_api_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + 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, gateway_id: str, api_id: str, **kwargs: Any + ) -> None: + """Deletes the specified API from the specified 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 api_id: API identifier. Must be unique in the current API Management service instance. + Required. + :type api_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_api_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class GatewayHostnameConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`gateway_hostname_configuration` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, gateway_id: str, hc_id: str, **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Get details of a hostname configuration. + + :param resource_group_name: The name of the resource group. The name is 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayHostnameConfigurationContract] = kwargs.pop("cls", None) + + _request = build_gateway_hostname_configuration_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayHostnameConfigurationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, gateway_id: str, hc_id: str, **kwargs: Any + ) -> bool: + """Checks that hostname configuration entity specified by identifier exists for specified Gateway + 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 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_hostname_configuration_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: _models.GatewayHostnameConfigurationContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :param 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: Union[_models.GatewayHostnameConfigurationContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayHostnameConfigurationContract: + """Creates of updates hostname configuration for a 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :param parameters: Is one of the following types: GatewayHostnameConfigurationContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayHostnameConfigurationContract. The GatewayHostnameConfigurationContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayHostnameConfigurationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_hostname_configuration_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayHostnameConfigurationContract, response.json()) + + 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, + gateway_id: str, + hc_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified hostname configuration from the specified 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 hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. Required. + :type hc_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_hostname_configuration_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + hc_id=hc_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.GatewayHostnameConfigurationContract"]: + """Lists the collection of hostname configurations for the specified 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| hostname + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GatewayHostnameConfigurationContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayHostnameConfigurationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_gateway_hostname_configuration_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayHostnameConfigurationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class GatewayCertificateAuthorityOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`gateway_certificate_authority` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, gateway_id: str, certificate_id: str, **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Get assigned Gateway Certificate Authority 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 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GatewayCertificateAuthorityContract] = kwargs.pop("cls", None) + + _request = build_gateway_certificate_authority_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayCertificateAuthorityContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, gateway_id: str, certificate_id: str, **kwargs: Any + ) -> bool: + """Checks if Certificate entity is assigned to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_certificate_authority_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + parameters: _models.GatewayCertificateAuthorityContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Assign Certificate entity to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Assign Certificate entity to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Assign Certificate entity to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + certificate_id: str, + parameters: Union[_models.GatewayCertificateAuthorityContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.GatewayCertificateAuthorityContract: + """Assign Certificate entity to Gateway entity as Certificate Authority. + + :param resource_group_name: The name of the resource group. The name is 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :param parameters: Is one of the following types: GatewayCertificateAuthorityContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GatewayCertificateAuthorityContract. The GatewayCertificateAuthorityContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GatewayCertificateAuthorityContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_gateway_certificate_authority_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GatewayCertificateAuthorityContract, response.json()) + + 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, + gateway_id: str, + certificate_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Remove relationship between Certificate Authority and Gateway 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 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. Required. + :type certificate_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_gateway_certificate_authority_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + certificate_id=certificate_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.GatewayCertificateAuthorityContract"]: + """Lists the collection of Certificate Authorities for the specified Gateway 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 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | eq, ne | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GatewayCertificateAuthorityContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayCertificateAuthorityContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GatewayCertificateAuthorityContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_gateway_certificate_authority_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GatewayCertificateAuthorityContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class GroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`group` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + _request = build_group_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_group_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: _models.GroupCreateParameters, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :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, + group_id: str, + parameters: Union[_models.GroupCreateParameters, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Create parameters. Is one of the following types: GroupCreateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupCreateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_group_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + 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, + group_id: str, + parameters: _models.GroupUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: Union[_models.GroupUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :param parameters: Update parameters. Is one of the following types: GroupUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GroupUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_group_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + 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, + group_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific group 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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_group_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.GroupContract"]: + """Lists a collection of groups 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GroupContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GroupContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GroupContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class GroupUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`group_user` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + group_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_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 group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of UserContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.UserContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_group_user_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.UserContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_group_user_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, 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 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. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + _request = build_group_user_create_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + 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, 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 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_group_user_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + group_id=group_id, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of UserContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.UserContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_group_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.UserContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_group_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + _request = build_workspace_group_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_group_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class IdentityProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`identity_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Gets the configuration details of the identity Provider configured in specified 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 identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.IdentityProviderContract] = kwargs.pop("cls", None) + + _request = build_identity_provider_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IdentityProviderContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + **kwargs: Any + ) -> bool: + """Gets the entity state (Etag) version of the identityProvider 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 identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_identity_provider_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: _models.IdentityProviderCreateContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Creates or Updates the IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Creates or Updates the IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Creates or Updates the IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: Union[_models.IdentityProviderCreateContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Creates or Updates the IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Create parameters. Is one of the following types: + IdentityProviderCreateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderCreateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IdentityProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_identity_provider_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IdentityProviderContract, response.json()) + + 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, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: _models.IdentityProviderUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + parameters: Union[_models.IdentityProviderUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.IdentityProviderContract: + """Updates an existing IdentityProvider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Update parameters. Is one of the following types: + IdentityProviderUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: IdentityProviderContract. The IdentityProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.IdentityProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_identity_provider_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.IdentityProviderContract, response.json()) + + 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, + identity_provider_name: Union[str, _models.IdentityProviderType], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes the specified identity provider configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_identity_provider_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> ItemPaged["_models.IdentityProviderContract"]: + """Lists a collection of Identity Provider configured in the specified 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 + :return: An iterator like instance of IdentityProviderContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.IdentityProviderContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_identity_provider_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.IdentityProviderContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_secrets( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, _models.IdentityProviderType], + **kwargs: Any + ) -> _models.ClientSecretContract: + """Gets the client secret details of the Identity Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param identity_provider_name: Identity Provider Type identifier. Known values are: "facebook", + "google", "microsoft", "twitter", "aad", and "aadB2C". Required. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :return: ClientSecretContract. The ClientSecretContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientSecretContract] = kwargs.pop("cls", None) + + _request = build_identity_provider_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + identity_provider_name=identity_provider_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientSecretContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class LoggerOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`logger` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.LoggerContract] = kwargs.pop("cls", None) + + _request = build_logger_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_logger_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: _models.LoggerContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :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, + logger_id: str, + parameters: Union[_models.LoggerContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Create parameters. Is one of the following types: LoggerContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_logger_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + 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, + logger_id: str, + parameters: _models.LoggerUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: Union[_models.LoggerUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :param parameters: Update parameters. Is one of the following types: LoggerUpdateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.LoggerUpdateContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: LoggerContract. The LoggerContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_logger_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.LoggerContract, response.json()) + + 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, + logger_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 logger_id: Logger identifier. Must be unique in the API Management service instance. + Required. + :type logger_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_logger_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + logger_id=logger_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.LoggerContract"]: + """Lists a collection of loggers in the specified 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of LoggerContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.LoggerContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.LoggerContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_logger_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.LoggerContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class NamedValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`named_value` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: NamedValueContract. The NamedValueContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamedValueContract] = kwargs.pop("cls", None) + + _request = build_named_value_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NamedValueContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_named_value_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + parameters: Union[_models.NamedValueCreateContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_named_value_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + named_value_id: str, + parameters: _models.NamedValueCreateContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, + named_value_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, + named_value_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, + named_value_id: str, + parameters: Union[_models.NamedValueCreateContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Create parameters. Is one of the following types: NamedValueCreateContract, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueCreateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + named_value_id=named_value_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + named_value_id: str, + parameters: Union[_models.NamedValueUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_named_value_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + named_value_id: str, + parameters: _models.NamedValueUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, + named_value_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, + named_value_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :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, + named_value_id: str, + parameters: Union[_models.NamedValueUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :param parameters: Update parameters. Is one of the following types: + NamedValueUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + named_value_id=named_value_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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 = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + named_value_id: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific named value from 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_named_value_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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, + is_key_vault_refresh_failed: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.NamedValueContract"]: + """Lists a collection of named values 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword is_key_vault_refresh_failed: When set to true, the response contains only named value + entities which failed refresh. Default value is None. + :paramtype is_key_vault_refresh_failed: bool + :return: An iterator like instance of NamedValueContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NamedValueContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_named_value_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, + is_key_vault_refresh_failed=is_key_vault_refresh_failed, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NamedValueContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_value( + self, resource_group_name: str, service_name: 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: NamedValueSecretContract. The NamedValueSecretContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NamedValueSecretContract] = kwargs.pop("cls", None) + + _request = build_named_value_list_value_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NamedValueSecretContract, response.json()) + + 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, named_value_id: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_named_value_refresh_secret_request( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, 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 named_value_id: Identifier of the NamedValue. Required. + :type named_value_id: str + :return: An instance of LROPoller that returns NamedValueContract. The NamedValueContract is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + named_value_id=named_value_id, + 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 = _deserialize(_models.NamedValueContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + +class NotificationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`notification` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: 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 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. The NotificationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_notification_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NotificationContract, response.json()) + + 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, + notification_name: Union[str, _models.NotificationName], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.NotificationContract: + """Create or Update API Management publisher 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 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: NotificationContract. The NotificationContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.NotificationContract] = kwargs.pop("cls", None) + + _request = build_notification_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.NotificationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_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 + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of NotificationContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.NotificationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.NotificationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_notification_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.NotificationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class NotificationRecipientUserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`notification_recipient_user` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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 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. The RecipientUserCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientUserCollection] = kwargs.pop("cls", None) + + _request = build_notification_recipient_user_list_by_notification_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientUserCollection, response.json()) + + 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, + 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_notification_recipient_user_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, + 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 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. The RecipientUserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientUserContract] = kwargs.pop("cls", None) + + _request = build_notification_recipient_user_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientUserContract, response.json()) + + 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, + 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 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_notification_recipient_user_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class NotificationRecipientEmailOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`notification_recipient_email` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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, + 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 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. The RecipientEmailCollection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientEmailCollection] = kwargs.pop("cls", None) + + _request = build_notification_recipient_email_list_by_notification_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientEmailCollection, response.json()) + + 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, + 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 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_notification_recipient_email_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, + 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 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. The RecipientEmailContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientEmailContract] = kwargs.pop("cls", None) + + _request = build_notification_recipient_email_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientEmailContract, response.json()) + + 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, + 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 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_notification_recipient_email_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + notification_name=notification_name, + email=email, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The RecipientUserCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientUserCollection] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientUserCollection, response.json()) + + 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: Workspace identifier. Must be unique in the current API Management + service instance. 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The RecipientUserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientUserContract] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientUserContract, response.json()) + + 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: Workspace identifier. Must be unique in the current API Management + service instance. 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_user_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The RecipientEmailCollection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientEmailCollection] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_email_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientEmailCollection, response.json()) + + 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: Workspace identifier. Must be unique in the current API Management + service instance. 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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_email_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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. The RecipientEmailContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.RecipientEmailContract] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_email_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.RecipientEmailContract, response.json()) + + 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: Workspace identifier. Must be unique in the current API Management + service instance. 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_notification_recipient_email_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class OpenIdConnectProviderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`open_id_connect_provider` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, opid: str, **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Gets specific OpenID Connect Provider without secrets. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OpenidConnectProviderContract] = kwargs.pop("cls", None) + + _request = build_open_id_connect_provider_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OpenidConnectProviderContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, opid: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the openIdConnectProvider 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 opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_open_id_connect_provider_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: _models.OpenidConnectProviderContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Creates or updates the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Creates or updates the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Creates or updates the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Create 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: Union[_models.OpenidConnectProviderContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Creates or updates the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Create parameters. Is one of the following types: + OpenidConnectProviderContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenidConnectProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_open_id_connect_provider_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OpenidConnectProviderContract, response.json()) + + 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, + opid: str, + parameters: _models.OpenidConnectProviderUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Updates the specific OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Updates the specific OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Updates the specific OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: Union[_models.OpenidConnectProviderUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.OpenidConnectProviderContract: + """Updates the specific OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :param parameters: Update parameters. Is one of the following types: + OpenidConnectProviderUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract or JSON + or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: OpenidConnectProviderContract. The OpenidConnectProviderContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.OpenidConnectProviderContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_open_id_connect_provider_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OpenidConnectProviderContract, response.json()) + + 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, + opid: str, + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> None: + """Deletes specific OpenID Connect Provider 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 opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_open_id_connect_provider_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.OpenidConnectProviderContract"]: + """Lists of all the OpenId Connect Providers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of OpenidConnectProviderContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.OpenidConnectProviderContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_open_id_connect_provider_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.OpenidConnectProviderContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_secrets( + self, resource_group_name: str, service_name: str, opid: str, **kwargs: Any + ) -> _models.ClientSecretContract: + """Gets the client secret details of the OpenID Connect Provider. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. Required. + :type opid: str + :return: ClientSecretContract. The ClientSecretContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientSecretContract] = kwargs.pop("cls", None) + + _request = build_open_id_connect_provider_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + opid=opid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientSecretContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class PolicyFragmentOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`policy_fragment` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: 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 id: A resource identifier. Required. + :type id: str + :keyword format: Policy fragment content format. Known values are: "xml" and "rawxml". Default + value is None. + :paramtype format: str or ~azure.mgmt.apimanagement.models.PolicyFragmentContentFormat + :return: PolicyFragmentContract. The PolicyFragmentContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyFragmentContract] = kwargs.pop("cls", None) + + _request = build_policy_fragment_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + format=format, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyFragmentContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 id: A resource identifier. Required. + :type id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_fragment_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + id: str, + parameters: Union[_models.PolicyFragmentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_fragment_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + id: str, + parameters: _models.PolicyFragmentContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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, + id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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, + id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :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, + id: str, + parameters: Union[_models.PolicyFragmentContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 id: A resource identifier. Required. + :type id: str + :param parameters: The policy fragment contents to apply. Is one of the following types: + PolicyFragmentContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyFragmentContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns PolicyFragmentContract. The + PolicyFragmentContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + id=id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.PolicyFragmentContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 id: A resource identifier. Required. + :type id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_fragment_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + orderby: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyFragmentContract"]: + """Gets all policy fragments. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword 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. + :paramtype filter: str + :keyword orderby: OData order by query option. Default value is None. + :paramtype orderby: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of PolicyFragmentContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyFragmentContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyFragmentContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_policy_fragment_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyFragmentContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_references( + self, + resource_group_name: str, + service_name: 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 id: A resource identifier. Required. + :type id: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: ResourceCollection. The ResourceCollection is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ResourceCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ResourceCollection] = kwargs.pop("cls", None) + + _request = build_policy_fragment_list_references_request( + resource_group_name=resource_group_name, + service_name=service_name, + id=id, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ResourceCollection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The PolicyRestrictionContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PolicyRestrictionContract] = kwargs.pop("cls", None) + + _request = build_policy_restriction_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyRestrictionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_restriction_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_restriction_id: str, + parameters: _models.PolicyRestrictionContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: + PolicyRestrictionContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restriction_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, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyRestrictionContract, response.json()) + + 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, + parameters: _models.PolicyRestrictionUpdateContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: The policy restriction to apply. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionUpdateContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: The policy restriction to apply. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: The policy restriction to apply. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :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, + parameters: Union[_models.PolicyRestrictionUpdateContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: The policy restriction to apply. Is one of the following types: + PolicyRestrictionUpdateContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PolicyRestrictionUpdateContract or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PolicyRestrictionContract. The PolicyRestrictionContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PolicyRestrictionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restriction_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyRestrictionContract, response.json()) + + 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, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_policy_restriction_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + policy_restriction_id=policy_restriction_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> ItemPaged["_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 PolicyRestrictionContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PolicyRestrictionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PolicyRestrictionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_policy_restriction_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyRestrictionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PortalConfigOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`portal_config` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, portal_config_id: str, **kwargs: Any + ) -> _models.PortalConfigContract: + """Get the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalConfigContract] = kwargs.pop("cls", None) + + _request = build_portal_config_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalConfigContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, portal_config_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_portal_config_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: _models.PortalConfigContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: Union[_models.PortalConfigContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Create or update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Is one of the following types: + PortalConfigContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalConfigContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_portal_config_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalConfigContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: _models.PortalConfigContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + portal_config_id: str, + parameters: Union[_models.PortalConfigContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.PortalConfigContract: + """Update the developer portal configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_config_id: Portal configuration identifier. Required. + :type portal_config_id: str + :param parameters: Update the developer portal configuration. Is one of the following types: + PortalConfigContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: PortalConfigContract. The PortalConfigContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalConfigContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_portal_config_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_config_id=portal_config_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalConfigContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> ItemPaged["_models.PortalConfigContract"]: + """Lists the developer portal configurations. + + :param resource_group_name: The name of the resource group. The name 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 PortalConfigContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PortalConfigContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PortalConfigContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_portal_config_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PortalConfigContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ClientApplicationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`client_application` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, client_application_id: str, **kwargs: Any + ) -> _models.ClientApplicationContract: + """Gets the details of the client application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :return: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientApplicationContract] = kwargs.pop("cls", None) + + _request = build_client_application_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, client_application_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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_client_application_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + parameters: _models.ClientApplicationContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationContract: + """Creates or Updates a client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationContract: + """Creates or Updates a client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationContract: + """Creates or Updates a client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_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: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + parameters: Union[_models.ClientApplicationContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ClientApplicationContract: + """Creates or Updates a client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param parameters: Create or update parameters. Is one of the following types: + ClientApplicationContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ClientApplicationContract or JSON or + IO[bytes] + :return: ClientApplicationContract. The ClientApplicationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClientApplicationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_client_application_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationContract, response.json()) + + 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, client_application_id: str, **kwargs: Any + ) -> None: + """Delete client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_client_application_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.ClientApplicationContract"]: + """Lists a collection of client applications in the specified 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 + :keyword 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 + |
state | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
|. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ClientApplicationContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ClientApplicationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ClientApplicationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_client_application_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ClientApplicationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_secrets( + self, resource_group_name: str, service_name: str, client_application_id: str, **kwargs: Any + ) -> _models.ClientApplicationSecretsContract: + """Retrived client application secrets. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :return: ClientApplicationSecretsContract. The ClientApplicationSecretsContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientApplicationSecretsContract] = kwargs.pop("cls", None) + + _request = build_client_application_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationSecretsContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ClientApplicationProductLinkOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`client_application_product_link` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Gets the product link for the client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :return: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ClientApplicationProductLinkContract] = kwargs.pop("cls", None) + + _request = build_client_application_product_link_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + client_application_product_link_id=client_application_product_link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationProductLinkContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + parameters: _models.ClientApplicationProductLinkContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Adds an Product to the specified Client Application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :param parameters: Create parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Adds an Product to the specified Client Application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :param parameters: Create parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Adds an Product to the specified Client Application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :param parameters: Create 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: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + client_application_product_link_id: str, + parameters: Union[_models.ClientApplicationProductLinkContract, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.ClientApplicationProductLinkContract: + """Adds an Product to the specified Client Application 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 client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :param parameters: Create parameters. Is one of the following types: + ClientApplicationProductLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract or JSON + or IO[bytes] + :return: ClientApplicationProductLinkContract. The ClientApplicationProductLinkContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ClientApplicationProductLinkContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_client_application_product_link_create_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + client_application_product_link_id=client_application_product_link_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ClientApplicationProductLinkContract, response.json()) + + 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, + client_application_id: str, + client_application_product_link_id: str, + **kwargs: Any + ) -> None: + """Deletes the specified Product from the specified client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :param client_application_product_link_id: Client Application Product Link identifier. Must be + unique in the current API Management service instance. Required. + :type client_application_product_link_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_client_application_product_link_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + client_application_product_link_id=client_application_product_link_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_by_client_applications( + self, + resource_group_name: str, + service_name: str, + client_application_id: str, + *, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.ClientApplicationProductLinkContract"]: + """Lists a collection of product links associated with the specified client application. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param client_application_id: Client Application identifier. Must be unique in the current API + Management service instance. Required. + :type client_application_id: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ClientApplicationProductLinkContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ClientApplicationProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ClientApplicationProductLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_client_application_product_link_list_by_client_applications_request( + resource_group_name=resource_group_name, + service_name=service_name, + client_application_id=client_application_id, + subscription_id=self._config.subscription_id, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ClientApplicationProductLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PortalRevisionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`portal_revision` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, portal_revision_id: str, **kwargs: Any + ) -> _models.PortalRevisionContract: + """Gets the developer portal's revision 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 portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :return: PortalRevisionContract. The PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PortalRevisionContract] = kwargs.pop("cls", None) + + _request = build_portal_revision_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_revision_id=portal_revision_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PortalRevisionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, portal_revision_id: str, **kwargs: Any + ) -> bool: + """Gets the developer portal revision 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 portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_portal_revision_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_revision_id=portal_revision_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: Union[_models.PortalRevisionContract, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_portal_revision_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_revision_id=portal_revision_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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]: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + portal_revision_id: str, + parameters: _models.PortalRevisionContract, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PortalRevisionContract]: + """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` + property indicates if the revision is publicly accessible. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PortalRevisionContract]: + """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` + property indicates if the revision is publicly accessible. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: JSON + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PortalRevisionContract]: + """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` + property indicates if the revision is publicly accessible. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param 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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: Union[_models.PortalRevisionContract, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PortalRevisionContract]: + """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` + property indicates if the revision is publicly accessible. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Is one of the following types: PortalRevisionContract, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or JSON or IO[bytes] + :return: An instance of LROPoller that returns PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalRevisionContract] = 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, + portal_revision_id=portal_revision_id, + parameters=parameters, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.PortalRevisionContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PortalRevisionContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PortalRevisionContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: Union[_models.PortalRevisionContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_portal_revision_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + portal_revision_id=portal_revision_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + portal_revision_id: str, + parameters: _models.PortalRevisionContract, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PortalRevisionContract]: + """Updates the description of specified portal revision or makes it current. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PortalRevisionContract]: + """Updates the description of specified portal revision or makes it current. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PortalRevisionContract]: + """Updates the description of specified portal revision or makes it current. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :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 PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + service_name: str, + portal_revision_id: str, + parameters: Union[_models.PortalRevisionContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> LROPoller[_models.PortalRevisionContract]: + """Updates the description of specified portal revision or makes it current. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param portal_revision_id: Portal revision identifier. Must be unique in the current API + Management service instance. Required. + :type portal_revision_id: str + :param parameters: Is one of the following types: PortalRevisionContract, JSON, IO[bytes] + Required. + :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns PortalRevisionContract. The + PortalRevisionContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PortalRevisionContract] = 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, + portal_revision_id=portal_revision_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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 = _deserialize(_models.PortalRevisionContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PortalRevisionContract].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PortalRevisionContract]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @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 + ) -> ItemPaged["_models.PortalRevisionContract"]: + """Lists developer portal's revisions. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: | Field | Supported operators | Supported functions | + |-------------|------------------------|-----------------------------------| + + |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| + |description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| + |isCurrent | eq, ne | |. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of PortalRevisionContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PortalRevisionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_portal_revision_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PortalRevisionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PrivateEndpointConnectionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`private_endpoint_connection` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_by_name( + self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the details of the Private Endpoint Connection 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 private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: PrivateEndpointConnection. The PrivateEndpointConnection is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connection_get_by_name_request( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(private_endpoint_connection_request, (IOBase, bytes)): + _content = private_endpoint_connection_request + else: + _content = json.dumps(private_endpoint_connection_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_private_endpoint_connection_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + private_endpoint_connection_name: str, + private_endpoint_connection_request: _models.PrivateEndpointConnectionRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: 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 private_endpoint_connection_name: str + :param private_endpoint_connection_request: Required. + :type private_endpoint_connection_request: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest + :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 PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: 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 private_endpoint_connection_name: str + :param private_endpoint_connection_request: Required. + :type private_endpoint_connection_request: JSON + :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 PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: 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 private_endpoint_connection_name: str + :param private_endpoint_connection_request: Required. + :type private_endpoint_connection_request: 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 PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: 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 private_endpoint_connection_name: str + :param private_endpoint_connection_request: Is one of the following types: + PrivateEndpointConnectionRequest, JSON, IO[bytes] Required. + :type private_endpoint_connection_request: + ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest or JSON or IO[bytes] + :return: An instance of LROPoller that returns PrivateEndpointConnection. The + PrivateEndpointConnection is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = 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, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection_request=private_endpoint_connection_request, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.PrivateEndpointConnection, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.PrivateEndpointConnection].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connection_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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, 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, service_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the specified Private Endpoint Connection. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + private_endpoint_connection_name=private_endpoint_connection_name, + 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 + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_service( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> ItemPaged["_models.PrivateEndpointConnection"]: + """Lists all private endpoint connections 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 + :return: An iterator like instance of PrivateEndpointConnection + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_private_endpoint_connection_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PrivateEndpointConnection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_private_link_resource( + self, resource_group_name: str, service_name: str, private_link_sub_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Gets the private link resources. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param private_link_sub_resource_name: The name of the private link associated with the Azure + resource. Required. + :type private_link_sub_resource_name: str + :return: PrivateLinkResource. The PrivateLinkResource is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connection_get_private_link_resource_request( + resource_group_name=resource_group_name, + service_name=service_name, + private_link_sub_resource_name=private_link_sub_resource_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_private_link_resources( + self, resource_group_name: str, service_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources. + + :param resource_group_name: The name of the resource group. The name 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: PrivateLinkResourceListResult. The PrivateLinkResourceListResult is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + _request = build_private_endpoint_connection_list_private_link_resources_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PrivateLinkResourceListResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ProductApiOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_api` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.ApiContract"]: + """Lists a collection of the APIs 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 + :keyword 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 |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ApiContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_api_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, product_id: str, api_id: str, **kwargs: Any + ) -> bool: + """Checks that API entity specified by identifier is associated with the Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_api_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, product_id: str, api_id: str, **kwargs: Any + ) -> _models.ApiContract: + """Adds an API 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_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. The ApiContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiContract] = kwargs.pop("cls", None) + + _request = build_product_api_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiContract, response.json()) + + 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_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_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: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_api_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + api_id=api_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ProductGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_group` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_models.GroupContract"]: + """Lists the collection of developer groups associated with 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | |
| displayName | filter | eq, ne | |
| + description | filter | eq, ne | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GroupContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GroupContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_group_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GroupContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, product_id: str, group_id: str, **kwargs: Any + ) -> bool: + """Checks that Group entity specified by identifier is associated with the Product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_group_check_entity_exists_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, product_id: str, group_id: str, **kwargs: Any + ) -> _models.GroupContract: + """Adds the association between the specified developer group with 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_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: GroupContract. The GroupContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GroupContract] = kwargs.pop("cls", None) + + _request = build_product_group_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GroupContract, response.json()) + + 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_id: str, **kwargs: Any + ) -> None: + """Deletes the association between the specified group and 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_id: Group identifier. Must be unique in the current API Management service + instance. Required. + :type group_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_group_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + product_id=product_id, + group_id=group_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class ProductSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`product_subscriptions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + 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 + ) -> ItemPaged["_models.SubscriptionContract"]: + """Lists the collection of subscriptions 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 product_id: Product identifier. Must be unique in the current API Management service + instance. Required. + :type product_id: str + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SubscriptionContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_subscriptions_list_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The ProductApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductApiLinkContract] = kwargs.pop("cls", None) + + _request = build_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductApiLinkContract, response.json()) + + 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. The ProductApiLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductApiLinkContract. The ProductApiLinkContract is compatible with MutableMapping + :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. The ProductApiLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + ProductApiLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductApiLinkContract or JSON or IO[bytes] + :return: ProductApiLinkContract. The ProductApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_api_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductApiLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductApiLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductApiLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductApiLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The ProductGroupLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ProductGroupLinkContract] = kwargs.pop("cls", None) + + _request = build_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductGroupLinkContract, response.json()) + + 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. The ProductGroupLinkContract is compatible with + MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ProductGroupLinkContract. The ProductGroupLinkContract is compatible with + MutableMapping + :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. The ProductGroupLinkContract is compatible with + MutableMapping + :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, JSON, 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 one of the following types: + ProductGroupLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract or JSON or + IO[bytes] + :return: ProductGroupLinkContract. The ProductGroupLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ProductGroupLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_product_group_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ProductGroupLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| groupId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of ProductGroupLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ProductGroupLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ProductGroupLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_product_group_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ProductGroupLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class GlobalSchemaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`global_schema` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: 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 schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: GlobalSchemaContract. The GlobalSchemaContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GlobalSchemaContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GlobalSchemaContract] = kwargs.pop("cls", None) + + _request = build_global_schema_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GlobalSchemaContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_global_schema_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_global_schema_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + schema_id: str, + parameters: _models.GlobalSchemaContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema 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 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GlobalSchemaContract. The GlobalSchemaContract + is compatible with MutableMapping + :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, + schema_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema 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 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GlobalSchemaContract. The GlobalSchemaContract + is compatible with MutableMapping + :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, + schema_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema 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 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] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GlobalSchemaContract. The GlobalSchemaContract + is compatible with MutableMapping + :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, + schema_id: str, + parameters: Union[_models.GlobalSchemaContract, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> LROPoller[_models.GlobalSchemaContract]: + """Creates new or updates existing specified Schema 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 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 one of the following types: + GlobalSchemaContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.GlobalSchemaContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: An instance of LROPoller that returns GlobalSchemaContract. The GlobalSchemaContract + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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, + schema_id=schema_id, + parameters=parameters, + etag=etag, + match_condition=match_condition, + 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["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = _deserialize(_models.GlobalSchemaContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, + schema_id: str, + *, + etag: str, + match_condition: MatchConditions, + **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 schema_id: Schema id identifier. Must be unique in the current API Management service + instance. Required. + :type schema_id: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_global_schema_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + schema_id=schema_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_models.GlobalSchemaContract"]: + """Lists a collection of schemas registered with 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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GlobalSchemaContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GlobalSchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GlobalSchemaContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_global_schema_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GlobalSchemaContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class TenantSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tenant_settings` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: str, + settings_type: Union[str, _models.SettingsTypeName], + **kwargs: Any + ) -> _models.TenantSettingsContract: + """Get tenant settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param settings_type: The identifier of the settings. "public" Required. + :type settings_type: str or ~azure.mgmt.apimanagement.models.SettingsTypeName + :return: TenantSettingsContract. The TenantSettingsContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TenantSettingsContract] = kwargs.pop("cls", None) + + _request = build_tenant_settings_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + settings_type=settings_type, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TenantSettingsContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.TenantSettingsContract"]: + """Public settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: Not used. Default value is None. + :paramtype filter: str + :return: An iterator like instance of TenantSettingsContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TenantSettingsContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tenant_settings_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TenantSettingsContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class SubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`subscription` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionContract] = kwargs.pop("cls", None) + + _request = build_subscription_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_subscription_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: _models.SubscriptionCreateParameters, + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: JSON, + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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: JSON + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: IO[bytes], + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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] + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :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, + sid: str, + parameters: Union[_models.SubscriptionCreateParameters, JSON, IO[bytes]], + *, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 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 one of the following types: + SubscriptionCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionCreateParameters or JSON or + IO[bytes] + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_subscription_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + notify=notify, + app_type=app_type, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + 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, + sid: str, + parameters: _models.SubscriptionUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype 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. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: Union[_models.SubscriptionUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :param parameters: Update parameters. Is one of the following types: + SubscriptionUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword 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. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: SubscriptionContract. The SubscriptionContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_subscription_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + notify=notify, + app_type=app_type, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionContract, response.json()) + + 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, + sid: str, + *, + etag: str, + match_condition: MatchConditions, + **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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_subscription_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.SubscriptionContract"]: + """Lists all subscriptions 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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of SubscriptionContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.SubscriptionContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_subscription_list_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SubscriptionContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def regenerate_primary_key( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, sid: str, **kwargs: Any + ) -> None: + """Regenerates primary key of existing subscription 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_subscription_regenerate_primary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, sid: str, **kwargs: Any + ) -> None: + """Regenerates secondary key of existing subscription 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_subscription_regenerate_secondary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. Required. + :type sid: str + :return: SubscriptionKeysContract. The SubscriptionKeysContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SubscriptionKeysContract] = kwargs.pop("cls", None) + + _request = build_subscription_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + sid=sid, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SubscriptionKeysContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The TagApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagApiLinkContract] = kwargs.pop("cls", None) + + _request = build_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagApiLinkContract, response.json()) + + 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. The TagApiLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagApiLinkContract. The TagApiLinkContract is compatible with MutableMapping + :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. The TagApiLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + TagApiLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagApiLinkContract or JSON or IO[bytes] + :return: TagApiLinkContract. The TagApiLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagApiLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_api_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagApiLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagApiLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagApiLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagApiLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_api_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagApiLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The TagOperationLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagOperationLinkContract] = kwargs.pop("cls", None) + + _request = build_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagOperationLinkContract, response.json()) + + 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. The TagOperationLinkContract is compatible with + MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagOperationLinkContract. The TagOperationLinkContract is compatible with + MutableMapping + :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. The TagOperationLinkContract is compatible with + MutableMapping + :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, JSON, 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 one of the following types: + TagOperationLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagOperationLinkContract or JSON or + IO[bytes] + :return: TagOperationLinkContract. The TagOperationLinkContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagOperationLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_operation_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagOperationLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| operationId + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagOperationLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagOperationLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagOperationLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_operation_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagOperationLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. The TagProductLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TagProductLinkContract] = kwargs.pop("cls", None) + + _request = build_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagProductLinkContract, response.json()) + + 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. The TagProductLinkContract is compatible with MutableMapping + :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: JSON, + *, + 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: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: TagProductLinkContract. The TagProductLinkContract is compatible with MutableMapping + :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. The TagProductLinkContract is compatible with MutableMapping + :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, JSON, 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 one of the following types: + TagProductLinkContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.TagProductLinkContract or JSON or IO[bytes] + :return: TagProductLinkContract. The TagProductLinkContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TagProductLinkContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tag_product_link_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, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TagProductLinkContract, response.json()) + + 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| productId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. Default + value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of TagProductLinkContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagProductLinkContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.TagProductLinkContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tag_product_link_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.TagProductLinkContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class TenantAccessOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tenant_access` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> _models.AccessInformationContract: + """Get tenant access information details without secrets. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AccessInformationContract] = kwargs.pop("cls", None) + + _request = build_tenant_access_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccessInformationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag( + self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> bool: + """Tenant access metadata. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: _models.AccessInformationCreateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: Union[_models.AccessInformationCreateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Is one of the + following types: AccessInformationCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessInformationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_access_create_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccessInformationContract, response.json()) + + 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, + access_name: Union[str, _models.AccessIdName], + parameters: _models.AccessInformationUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, _models.AccessIdName], + parameters: Union[_models.AccessInformationUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.AccessInformationContract: + """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :param parameters: Parameters supplied to retrieve the Tenant Access Information. Is one of the + following types: AccessInformationUpdateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters or JSON or + IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: AccessInformationContract. The AccessInformationContract is compatible with + MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AccessInformationContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_access_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccessInformationContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_by_service( + self, resource_group_name: str, service_name: str, *, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.AccessInformationContract"]: + """Returns list of access infos - for Git and Management endpoints. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :keyword filter: Not used. Default value is None. + :paramtype filter: str + :return: An iterator like instance of AccessInformationContract + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AccessInformationContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AccessInformationContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_tenant_access_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AccessInformationContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def regenerate_primary_key( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> None: + """Regenerate primary access key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_regenerate_primary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> None: + """Regenerate secondary access key. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_regenerate_secondary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> _models.AccessInformationSecretsContract: + """Get tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: AccessInformationSecretsContract. The AccessInformationSecretsContract is compatible + with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.AccessInformationSecretsContract] = kwargs.pop("cls", None) + + _request = build_tenant_access_list_secrets_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AccessInformationSecretsContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + +class TenantAccessGitOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tenant_access_git` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def regenerate_primary_key( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> None: + """Regenerate primary access key for GIT. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_git_regenerate_primary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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, access_name: Union[str, _models.AccessIdName], **kwargs: Any + ) -> None: + """Regenerate secondary access key for GIT. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param access_name: The identifier of the Access configuration. Known values are: "access" and + "gitAccess". Required. + :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_tenant_access_git_regenerate_secondary_key_request( + resource_group_name=resource_group_name, + service_name=service_name, + access_name=access_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +class TenantConfigurationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`tenant_configuration` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _deploy_initial( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_configuration_deploy_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_deploy( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: _models.DeployConfigurationParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation applies changes from the specified Git branch to the configuration database. + This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Deploy Configuration parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_deploy( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation applies changes from the specified Git branch to the configuration database. + This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Deploy Configuration parameters. Required. + :type parameters: JSON + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_deploy( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation applies changes from the specified Git branch to the configuration database. + This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Deploy Configuration 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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_deploy( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation applies changes from the specified Git branch to the configuration database. + This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Deploy Configuration parameters. Is one of the following types: + DeployConfigurationParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._deploy_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.OperationResultContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + def _save_initial( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.SaveConfigurationParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_configuration_save_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_save( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: _models.SaveConfigurationParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Save Configuration parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_save( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Save Configuration parameters. Required. + :type parameters: JSON + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_save( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Save Configuration 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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_save( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.SaveConfigurationParameter, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Save Configuration parameters. Is one of the following types: + SaveConfigurationParameter, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter or JSON or + IO[bytes] + :return: An instance of LROPoller that returns OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._save_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.OperationResultContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + def _validate_initial( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_tenant_configuration_validate_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: _models.DeployConfigurationParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Validate Configuration parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Validate Configuration parameters. Required. + :type parameters: JSON + :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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Validate Configuration 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 OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + parameters: Union[_models.DeployConfigurationParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.OperationResultContract]: + """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param parameters: Validate Configuration parameters. Is one of the following types: + DeployConfigurationParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or JSON or + IO[bytes] + :return: An instance of LROPoller that returns OperationResultContract. The + OperationResultContract is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + 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._validate_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + parameters=parameters, + 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 = pipeline_response.http_response + deserialized = _deserialize(_models.OperationResultContract, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) + + @distributed_trace + def get_sync_state( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, _models.ConfigurationIdName], + **kwargs: Any + ) -> _models.TenantConfigurationSyncStateContract: + """Gets the status of the most recent synchronization between the configuration database and the + Git repository. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param configuration_name: 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. "configuration" Required. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :return: TenantConfigurationSyncStateContract. The TenantConfigurationSyncStateContract is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.TenantConfigurationSyncStateContract] = kwargs.pop("cls", None) + + _request = build_tenant_configuration_get_sync_state_request( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.TenantConfigurationSyncStateContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class UserOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any) -> _models.UserContract: + """Gets the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + _request = build_user_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_entity_tag(self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any) -> bool: + """Gets the entity state (Etag) version of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :return: bool + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_user_get_entity_tag_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: _models.UserCreateParameters, + *, + notify: Optional[bool] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.UserContract: + """Creates or Updates a 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 parameters: Create or update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters + :keyword notify: Send an Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: JSON, + *, + notify: Optional[bool] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.UserContract: + """Creates or Updates a 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 parameters: Create or update parameters. Required. + :type parameters: JSON + :keyword notify: Send an Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: IO[bytes], + *, + notify: Optional[bool] = None, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.UserContract: + """Creates or Updates a 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 parameters: Create or update parameters. Required. + :type parameters: IO[bytes] + :keyword notify: Send an Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: Union[_models.UserCreateParameters, JSON, IO[bytes]], + *, + notify: Optional[bool] = None, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs: Any + ) -> _models.UserContract: + """Creates or Updates a 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 parameters: Create or update parameters. Is one of the following types: + UserCreateParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters or JSON or IO[bytes] + :keyword notify: Send an Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_user_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + notify=notify, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + 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, + user_id: str, + parameters: _models.UserUpdateParameters, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserContract: + """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param parameters: Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserContract: + """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param parameters: Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserContract: + """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param parameters: Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: Union[_models.UserUpdateParameters, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **kwargs: Any + ) -> _models.UserContract: + """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :param parameters: Update parameters. Is one of the following types: UserUpdateParameters, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: UserContract. The UserContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UserContract] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_user_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + service_name: str, + user_id: str, + *, + etag: str, + match_condition: MatchConditions, + delete_subscriptions: Optional[bool] = None, + notify: Optional[bool] = None, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_user_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + delete_subscriptions=delete_subscriptions, + notify=notify, + app_type=app_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["location"] = self._deserialize("str", response.headers.get("location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + 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, + service_name: str, + user_id: str, + *, + etag: str, + match_condition: MatchConditions, + 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword delete_subscriptions: Whether to delete user's subscription or not. Default value is + None. + :paramtype delete_subscriptions: bool + :keyword notify: Send an Account Closed Email notification to the User. Default value is None. + :paramtype notify: bool + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + 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, + etag=etag, + match_condition=match_condition, + delete_subscriptions=delete_subscriptions, + notify=notify, + app_type=app_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): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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_service( + self, + resource_group_name: str, + service_name: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.UserContract"]: + """Lists a collection of registered users in the specified 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 + :keyword 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 + |
| state | filter | eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | + |
| note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| groups | expand | | |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :keyword expand_groups: Detailed Group in response. Default value is None. + :paramtype expand_groups: bool + :return: An iterator like instance of UserContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.UserContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_user_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, + expand_groups=expand_groups, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.UserContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def generate_sso_url( + self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any + ) -> _models.GenerateSsoUrlResult: + """Retrieves a redirection URL containing an authentication token for signing a given user into + the developer portal. + + :param resource_group_name: The name of the resource group. The name is 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 + :return: GenerateSsoUrlResult. The GenerateSsoUrlResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.GenerateSsoUrlResult] = kwargs.pop("cls", None) + + _request = build_user_generate_sso_url_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.GenerateSsoUrlResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def get_shared_access_token( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: _models.UserTokenParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserTokenResult: + """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UserTokenResult. The UserTokenResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def get_shared_access_token( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserTokenResult: + """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UserTokenResult. The UserTokenResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def get_shared_access_token( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UserTokenResult: + """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token 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: UserTokenResult. The UserTokenResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def get_shared_access_token( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: Union[_models.UserTokenParameters, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.UserTokenResult: + """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Is one of the following types: + UserTokenParameters, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters or JSON or IO[bytes] + :return: UserTokenResult. The UserTokenResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UserTokenResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_user_get_shared_access_token_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.UserTokenResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class UserGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user_group` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, + resource_group_name: str, + service_name: str, + user_id: str, + *, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.GroupContract"]: + """Lists all user 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 user_id: User identifier. Must be unique in the current API Management service instance. + Required. + :type user_id: str + :keyword 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 |
. Default value is None. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of GroupContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GroupContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.GroupContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_user_group_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + filter=filter, + top=top, + skip=skip, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.GroupContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class UserIdentitiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user_identities` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any + ) -> ItemPaged["_models.UserIdentityContract"]: + """List of all user identities. + + :param resource_group_name: The name of the resource group. The name is 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 + :return: An iterator like instance of UserIdentityContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserIdentityContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.UserIdentityContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_user_identities_list_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.UserIdentityContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class UserConfirmationPasswordOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`user_confirmation_password` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def send( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + service_name: str, + user_id: str, + *, + app_type: Optional[Union[str, _models.AppType]] = None, + **kwargs: Any + ) -> None: + """Sends confirmation. + + :param resource_group_name: The name of the resource group. The name is 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 + :keyword 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. + :paramtype app_type: str or ~azure.mgmt.apimanagement.models.AppType + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_user_confirmation_password_send_request( + resource_group_name=resource_group_name, + service_name=service_name, + user_id=user_id, + subscription_id=self._config.subscription_id, + app_type=app_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The ApiManagementWorkspaceLinksResource is + compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiManagementWorkspaceLinksResource] = kwargs.pop("cls", None) + + _request = build_api_management_workspace_link_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiManagementWorkspaceLinksResource, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + ) -> ItemPaged["_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 ApiManagementWorkspaceLinksResource + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementWorkspaceLinksResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementWorkspaceLinksResource]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_workspace_links_list_by_service_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementWorkspaceLinksResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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.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. The WorkspaceContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.WorkspaceContract] = kwargs.pop("cls", None) + + _request = build_workspace_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkspaceContract, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @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 + :rtype: bool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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 + + @overload + def create_or_update( + self, + resource_group_name: str, + service_name: str, + workspace_id: str, + parameters: _models.WorkspaceContract, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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: JSON, + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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], + *, + content_type: str = "application/json", + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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. 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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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, JSON, IO[bytes]], + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = 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 one of the following types: WorkspaceContract, JSON, + IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Default value is + None. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Default value is None. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_create_or_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkspaceContract, response.json()) + + 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, + parameters: _models.WorkspaceContract, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Workspace Update parameters. Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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, + parameters: JSON, + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Workspace Update parameters. Required. + :type parameters: JSON + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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, + parameters: IO[bytes], + *, + etag: str, + match_condition: MatchConditions, + 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 parameters: Workspace Update parameters. Required. + :type parameters: IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :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, + parameters: Union[_models.WorkspaceContract, JSON, IO[bytes]], + *, + etag: str, + match_condition: MatchConditions, + **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 parameters: Workspace Update parameters. Is one of the following types: + WorkspaceContract, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.apimanagement.models.WorkspaceContract or JSON or IO[bytes] + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: WorkspaceContract. The WorkspaceContract is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.WorkspaceContract + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_workspace_update_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.WorkspaceContract, response.json()) + + 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, + *, + etag: str, + match_condition: MatchConditions, + **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 + :keyword etag: check if resource is changed. Set None to skip checking etag. Required. + :paramtype etag: str + :keyword match_condition: The match condition to use upon the etag. Required. + :paramtype match_condition: ~azure.core.MatchConditions + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + if match_condition == MatchConditions.IfNotModified: + error_map[412] = ResourceModifiedError + elif match_condition == MatchConditions.IfPresent: + error_map[412] = ResourceNotFoundError + elif match_condition == MatchConditions.IfMissing: + error_map[412] = ResourceExistsError + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_workspace_delete_request( + resource_group_name=resource_group_name, + service_name=service_name, + workspace_id=workspace_id, + subscription_id=self._config.subscription_id, + etag=etag, + match_condition=match_condition, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @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 + ) -> ItemPaged["_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 + :keyword 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. + :paramtype filter: str + :keyword top: Number of records to return. Default value is None. + :paramtype top: int + :keyword skip: Number of records to skip. Default value is None. + :paramtype skip: int + :return: An iterator like instance of WorkspaceContract + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.WorkspaceContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.WorkspaceContract]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_workspace_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.WorkspaceContract], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class ApiExportOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_export` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get( + self, + resource_group_name: str, + service_name: 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 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 + :keyword format: Format in which to export the Api Details to the Storage Blob with Sas Key + valid 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. + :paramtype format: str or ~azure.mgmt.apimanagement.models.ExportFormat + :keyword export: Query parameter required to export the API details. "true" Required. + :paramtype export: str or ~azure.mgmt.apimanagement.models.ExportApi + :return: ApiExportResult. The ApiExportResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiExportResult] = kwargs.pop("cls", None) + + _request = build_api_export_get_request( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + subscription_id=self._config.subscription_id, + format=format, + export=export, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiExportResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ApiManagementSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s + :attr:`api_management_skus` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.ApiManagementSku"]: + """Gets the list of Microsoft.ApiManagement SKUs available for your Subscription. + + :return: An iterator like instance of ApiManagementSku + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementSku] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ApiManagementSku]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 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_api_management_skus_list_request( + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + 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 + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ApiManagementSku], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + :keyword 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. + :paramtype format: str or ~azure.mgmt.apimanagement.models.ExportFormat + :keyword export: Query parameter required to export the API details. "true" Required. + :paramtype export: str or ~azure.mgmt.apimanagement.models.ExportApi + :return: ApiExportResult. The ApiExportResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ApiExportResult] = kwargs.pop("cls", None) + + _request = build_workspace_api_export_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=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ApiExportResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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. The OperationStatusResult is compatible with MutableMapping + :rtype: ~azure.mgmt.apimanagement.models.OperationStatusResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.OperationStatusResult] = kwargs.pop("cls", None) + + _request = build_operation_status_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("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]: + if _stream: + 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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationStatusResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +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. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: ApiManagementClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = 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 + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_operations_results_get_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) # type: ignore + + +class _ApiManagementClientOperationsMixin( + ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], ApiManagementClientConfiguration] +): + + 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, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 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 = kwargs.pop("params", {}) or {} + + 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" + _content = None + if isinstance(connectivity_check_request_params, (IOBase, bytes)): + _content = connectivity_check_request_params + else: + _content = json.dumps(connectivity_check_request_params, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_api_management_perform_connectivity_check_async_request( + resource_group_name=resource_group_name, + service_name=service_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _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 = _failsafe_deserialize( + _models.ErrorResponse, + 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["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: _models.ConnectivityCheckRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectivityCheckResponse]: + """Performs a connectivity check between the API Management service and a given destination, and + returns metrics for the connection, as well as errors encountered while trying to establish it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. Required. + :type connectivity_check_request_params: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest + :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 ConnectivityCheckResponse. The + ConnectivityCheckResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectivityCheckResponse]: + """Performs a connectivity check between the API Management service and a given destination, and + returns metrics for the connection, as well as errors encountered while trying to establish it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. Required. + :type connectivity_check_request_params: JSON + :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 ConnectivityCheckResponse. The + ConnectivityCheckResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectivityCheckResponse]: + """Performs a connectivity check between the API Management service and a given destination, and + returns metrics for the connection, as well as errors encountered while trying to establish it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. Required. + :type connectivity_check_request_params: 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 ConnectivityCheckResponse. The + ConnectivityCheckResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_perform_connectivity_check_async( + self, + resource_group_name: str, + service_name: str, + connectivity_check_request_params: Union[_models.ConnectivityCheckRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.ConnectivityCheckResponse]: + """Performs a connectivity check between the API Management service and a given destination, and + returns metrics for the connection, as well as errors encountered while trying to establish it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param service_name: The name of the API Management service. Required. + :type service_name: str + :param connectivity_check_request_params: Connectivity Check request parameters. Is one of the + following types: ConnectivityCheckRequest, JSON, IO[bytes] Required. + :type connectivity_check_request_params: + ~azure.mgmt.apimanagement.models.ConnectivityCheckRequest or JSON or IO[bytes] + :return: An instance of LROPoller that returns ConnectivityCheckResponse. The + ConnectivityCheckResponse is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ConnectivityCheckResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ConnectivityCheckResponse] = 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._perform_connectivity_check_async_initial( + resource_group_name=resource_group_name, + service_name=service_name, + connectivity_check_request_params=connectivity_check_request_params, + 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["location"] = self._deserialize("str", response.headers.get("location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = _deserialize(_models.ConnectivityCheckResponse, response.json()) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ConnectivityCheckResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ConnectivityCheckResponse]( + self._client, raw_result, get_long_running_output, polling_method # 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 deleted file mode 100644 index b4670249ce0b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_operations_results_operations.py +++ /dev/null @@ -1,143 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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 = { - 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 deleted file mode 100644 index 81aa9a6542a9..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_outbound_network_dependencies_endpoints_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/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"), - "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) - - -class OutboundNetworkDependenciesEndpointsOperations: # 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:`outbound_network_dependencies_endpoints` 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 - ) -> _models.OutboundEnvironmentEndpointList: - """Gets the network endpoints of all outbound dependencies of a ApiManagement 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: OutboundEnvironmentEndpointList or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.OutboundEnvironmentEndpointList - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.OutboundEnvironmentEndpointList] = 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.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("OutboundEnvironmentEndpointList", 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/_patch.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_patch.py index f7dd32510333..87676c65a8f0 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_patch.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_patch.py @@ -1,14 +1,15 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): 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 deleted file mode 100644 index 17bb2bc490df..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_description_operations.py +++ /dev/null @@ -1,169 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - *, - scope: Optional[Union[str, _models.PolicyScopeContract]] = 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions", - ) # 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 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) - - -class PolicyDescriptionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`policy_description` 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, - scope: Optional[Union[str, _models.PolicyScopeContract]] = None, - **kwargs: Any - ) -> _models.PolicyDescriptionCollection: - """Lists all policy descriptions. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param scope: Policy scope. Known values are: "Tenant", "Product", "Api", "Operation", and - "All". Default value is None. - :type scope: str or ~azure.mgmt.apimanagement.models.PolicyScopeContract - :return: PolicyDescriptionCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PolicyDescriptionCollection] = 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, - scope=scope, - 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("PolicyDescriptionCollection", 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/_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_fragment_operations.py deleted file mode 100644 index 3464e884fd4a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_fragment_operations.py +++ /dev/null @@ -1,967 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 PolicyFragmentOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - id: str, - parameters: Union[_models.PolicyFragmentContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - 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, - 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 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, - 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 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, - 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 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, - 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, 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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/_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py deleted file mode 100644 index d4531c429b18..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py +++ /dev/null @@ -1,735 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 PolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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_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. - 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 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 = { - 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("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, policy_id: Union[str, _models.PolicyIdName], **kwargs: Any - ) -> bool: - """Gets the entity state (Etag) version of the Global policy definition 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_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 = { - 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_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, - policy_id: Union[str, _models.PolicyIdName], - format: Union[str, _models.PolicyExportFormat] = "xml", - **kwargs: Any - ) -> _models.PolicyContract: - """Get the Global policy definition 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_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 = { - 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, - 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, - 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 the global policy 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_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, - 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 the global policy 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_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, - policy_id: Union[str, _models.PolicyIdName], - parameters: Union[_models.PolicyContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.PolicyContract: - """Creates or updates the global policy 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_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 = { - 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, - 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, - policy_id: Union[str, _models.PolicyIdName], - if_match: str, - **kwargs: Any - ) -> None: - """Deletes the global policy 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_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 = { - 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_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/_policy_restriction_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_operations.py deleted file mode 100644 index 6e789e40135b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_operations.py +++ /dev/null @@ -1,934 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index d2fe70e707e0..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_restriction_validations_operations.py +++ /dev/null @@ -1,215 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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 = { - 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 deleted file mode 100644 index 9e4d3f01fc8b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_config_operations.py +++ /dev/null @@ -1,799 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalconfigs", - ) # 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) - - -def build_get_entity_tag_request( - resource_group_name: str, service_name: str, portal_config_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/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"), - "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])?$", - ), - "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_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, portal_config_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/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"), - "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])?$", - ), - "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_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_update_request( - resource_group_name: str, - service_name: str, - portal_config_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-05-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}/portalconfigs/{portalConfigId}", - ) # 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])?$", - ), - "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_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_create_or_update_request( - resource_group_name: str, - service_name: str, - portal_config_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-05-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}/portalconfigs/{portalConfigId}", - ) # 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])?$", - ), - "portalConfigId": _SERIALIZER.url("portal_config_id", portal_config_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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -class PortalConfigOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`portal_config` 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.PortalConfigContract"]: - """Lists the developer portal configurations. - - :param resource_group_name: The name of the resource group. The name 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 PortalConfigContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PortalConfigContract] - :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.PortalConfigCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("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: - """Gets the entity state (Etag) version of the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - portal_config_id=portal_config_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, portal_config_id: str, **kwargs: Any - ) -> _models.PortalConfigContract: - """Get the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_id: str - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalConfigContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_config_id=portal_config_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("PortalConfigContract", 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, - portal_config_id: str, - if_match: str, - parameters: _models.PortalConfigContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalConfigContract: - """Update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalConfigContract: - """Update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. 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: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: Union[_models.PortalConfigContract, IO[bytes]], - **kwargs: Any - ) -> _models.PortalConfigContract: - """Update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. Is either a PortalConfigContract - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract or IO[bytes] - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalConfigContract] = 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, "PortalConfigContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_config_id=portal_config_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) - - deserialized = self._deserialize("PortalConfigContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: _models.PortalConfigContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalConfigContract: - """Create or update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalConfigContract: - """Create or update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. 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: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_config_id: str, - if_match: str, - parameters: Union[_models.PortalConfigContract, IO[bytes]], - **kwargs: Any - ) -> _models.PortalConfigContract: - """Create or update the developer portal configuration. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_config_id: Portal configuration identifier. Required. - :type portal_config_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 the developer portal configuration. Is either a PortalConfigContract - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalConfigContract or IO[bytes] - :return: PortalConfigContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalConfigContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalConfigContract] = 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, "PortalConfigContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_config_id=portal_config_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) - - deserialized = self._deserialize("PortalConfigContract", 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/_portal_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py deleted file mode 100644 index 8a1634354116..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_revision_operations.py +++ /dev/null @@ -1,1005 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions", - ) # 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, portal_revision_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", - ) # 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])?$", - ), - "portalRevisionId": _SERIALIZER.url( - "portal_revision_id", portal_revision_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, portal_revision_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}", - ) # 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])?$", - ), - "portalRevisionId": _SERIALIZER.url( - "portal_revision_id", portal_revision_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, portal_revision_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-05-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}/portalRevisions/{portalRevisionId}", - ) # 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])?$", - ), - "portalRevisionId": _SERIALIZER.url( - "portal_revision_id", portal_revision_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 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, - portal_revision_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-05-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}/portalRevisions/{portalRevisionId}", - ) # 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])?$", - ), - "portalRevisionId": _SERIALIZER.url( - "portal_revision_id", portal_revision_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) - - -class PortalRevisionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`portal_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, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PortalRevisionContract"]: - """Lists developer portal's revisions. - - :param resource_group_name: The name of the resource group. The name is 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: .. list-table:: - :header-rows: 1 - - * - Field - - Supported operators - - Supported functions - * - - - - |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| - |description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| - |isCurrent | 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 - :return: An iterator like instance of either PortalRevisionContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :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.PortalRevisionCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("PortalRevisionCollection", 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_revision_id: str, **kwargs: Any - ) -> bool: - """Gets the developer portal revision 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 portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - portal_revision_id=portal_revision_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, portal_revision_id: str, **kwargs: Any - ) -> _models.PortalRevisionContract: - """Gets the developer portal's revision 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 portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :return: PortalRevisionContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalRevisionContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalRevisionContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_revision_id=portal_revision_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("PortalRevisionContract", 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, - portal_revision_id: str, - parameters: Union[_models.PortalRevisionContract, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, "PortalRevisionContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_revision_id=portal_revision_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) - - _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]: - 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, - portal_revision_id: str, - parameters: _models.PortalRevisionContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PortalRevisionContract]: - """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` - property indicates if the revision is publicly accessible. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :param parameters: Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract - :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 PortalRevisionContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PortalRevisionContract]: - """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` - property indicates if the revision is publicly accessible. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :param 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 PortalRevisionContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - parameters: Union[_models.PortalRevisionContract, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PortalRevisionContract]: - """Creates a new developer portal's revision by running the portal's publishing. The ``isCurrent`` - property indicates if the revision is publicly accessible. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_id: str - :param parameters: Is either a PortalRevisionContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or IO[bytes] - :return: An instance of LROPoller that returns either PortalRevisionContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :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.PortalRevisionContract] = 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, - portal_revision_id=portal_revision_id, - 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")) - 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.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.PortalRevisionContract].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PortalRevisionContract]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _update_initial( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - if_match: str, - parameters: Union[_models.PortalRevisionContract, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, "PortalRevisionContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - portal_revision_id=portal_revision_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, - portal_revision_id: str, - if_match: str, - parameters: _models.PortalRevisionContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PortalRevisionContract]: - """Updates the description of specified portal revision or makes it current. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_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: Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract - :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 PortalRevisionContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PortalRevisionContract]: - """Updates the description of specified portal revision or makes it current. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_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: 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 PortalRevisionContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_update( - self, - resource_group_name: str, - service_name: str, - portal_revision_id: str, - if_match: str, - parameters: Union[_models.PortalRevisionContract, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PortalRevisionContract]: - """Updates the description of specified portal revision or makes it current. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param portal_revision_id: Portal revision identifier. Must be unique in the current API - Management service instance. Required. - :type portal_revision_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: Is either a PortalRevisionContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalRevisionContract or IO[bytes] - :return: An instance of LROPoller that returns either PortalRevisionContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PortalRevisionContract] - :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.PortalRevisionContract] = 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, - portal_revision_id=portal_revision_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("PortalRevisionContract", 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.PortalRevisionContract].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PortalRevisionContract]( - 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_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py deleted file mode 100644 index d77a8f74f910..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_portal_settings_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings", - ) # 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 PortalSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`portal_settings` 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 - ) -> _models.PortalSettingsCollection: - """Lists a collection of portalsettings 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 - :return: PortalSettingsCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSettingsCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSettingsCollection] = 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.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("PortalSettingsCollection", 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/_private_endpoint_connection_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py deleted file mode 100644 index 9f776ad2a9ce..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_private_endpoint_connection_operations.py +++ /dev/null @@ -1,928 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/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"), - "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_by_name_request( - resource_group_name: str, - service_name: str, - private_endpoint_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # 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])?$", - ), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_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, - private_endpoint_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-05-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}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # 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])?$", - ), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_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 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, - private_endpoint_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateEndpointConnections/{privateEndpointConnectionName}", - ) # 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])?$", - ), - "privateEndpointConnectionName": _SERIALIZER.url( - "private_endpoint_connection_name", private_endpoint_connection_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_private_link_resources_request( # pylint: disable=name-too-long - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources", - ) # 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) - - -def build_get_private_link_resource_request( - resource_group_name: str, - service_name: str, - private_link_sub_resource_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/privateLinkResources/{privateLinkSubResourceName}", - ) # 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])?$", - ), - "privateLinkSubResourceName": _SERIALIZER.url( - "private_link_sub_resource_name", private_link_sub_resource_name, "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 PrivateEndpointConnectionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`private_endpoint_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_service( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - """Lists all private endpoint connections 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 - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - :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.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("PrivateEndpointConnectionListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return 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_by_name( - self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> _models.PrivateEndpointConnection: - """Gets the details of the Private Endpoint Connection 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 private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateEndpointConnection] = kwargs.pop("cls", None) - - _request = build_get_by_name_request( - resource_group_name=resource_group_name, - service_name=service_name, - private_endpoint_connection_name=private_endpoint_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("PrivateEndpointConnection", 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, - service_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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(private_endpoint_connection_request, (IOBase, bytes)): - _content = private_endpoint_connection_request - else: - _json = self._serialize.body(private_endpoint_connection_request, "PrivateEndpointConnectionRequest") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - private_endpoint_connection_name=private_endpoint_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, 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_create_or_update( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection_request: _models.PrivateEndpointConnectionRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection_request: Required. - :type private_endpoint_connection_request: - ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest - :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 PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection_request: Required. - :type private_endpoint_connection_request: 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 PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create_or_update( - self, - resource_group_name: str, - service_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection_request: Union[_models.PrivateEndpointConnectionRequest, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - """Creates a new Private Endpoint Connection 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 private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: str - :param private_endpoint_connection_request: Is either a PrivateEndpointConnectionRequest type - or a IO[bytes] type. Required. - :type private_endpoint_connection_request: - ~azure.mgmt.apimanagement.models.PrivateEndpointConnectionRequest or IO[bytes] - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.PrivateEndpointConnection] - :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.PrivateEndpointConnection] = 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, - private_endpoint_connection_name=private_endpoint_connection_name, - private_endpoint_connection_request=private_endpoint_connection_request, - 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("PrivateEndpointConnection", 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.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - service_name=service_name, - private_endpoint_connection_name=private_endpoint_connection_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, 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, service_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes the specified Private Endpoint Connection. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param private_endpoint_connection_name: Name of the private endpoint connection. Required. - :type private_endpoint_connection_name: 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, - service_name=service_name, - private_endpoint_connection_name=private_endpoint_connection_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): # 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 - - @distributed_trace - def list_private_link_resources( - self, resource_group_name: str, service_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: - """Gets the private link resources. - - :param resource_group_name: The name of the resource group. The name 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: PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResourceListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - _request = build_list_private_link_resources_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) - - _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("PrivateLinkResourceListResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_private_link_resource( - self, resource_group_name: str, service_name: str, private_link_sub_resource_name: str, **kwargs: Any - ) -> _models.PrivateLinkResource: - """Gets the private link resources. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param private_link_sub_resource_name: Name of the private link resource. Required. - :type private_link_sub_resource_name: str - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PrivateLinkResource] = kwargs.pop("cls", None) - - _request = build_get_private_link_resource_request( - resource_group_name=resource_group_name, - service_name=service_name, - private_link_sub_resource_name=private_link_sub_resource_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("PrivateLinkResource", 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/_product_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_link_operations.py deleted file mode 100644 index 79c6301175fb..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_link_operations.py +++ /dev/null @@ -1,645 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index f6ccbd945042..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py +++ /dev/null @@ -1,541 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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}/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])?$", - ), - "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_check_entity_exists_request( - resource_group_name: str, service_name: str, product_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-05-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}/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])?$", - ), - "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"), - } - - _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, product_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-05-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}/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])?$", - ), - "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"), - } - - _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, product_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-05-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}/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])?$", - ), - "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"), - } - - _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 ProductApiOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`product_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_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.ApiContract"]: - """Lists a collection of the APIs 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 |
|-------------|-------------|-------------|-------------|
| 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 |
. 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 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 = { - 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("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 check_entity_exists( - self, resource_group_name: str, service_name: str, product_id: str, api_id: str, **kwargs: Any - ) -> bool: - """Checks that API entity specified by identifier is associated with the Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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 = { - 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, - product_id=product_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 [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 - return 200 <= response.status_code <= 299 - - @distributed_trace - def create_or_update( - self, resource_group_name: str, service_name: str, product_id: str, api_id: str, **kwargs: Any - ) -> _models.ApiContract: - """Adds an API 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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 = { - 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_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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, 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("ApiContract", 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_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_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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_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, 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_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_link_operations.py deleted file mode 100644 index 35b650f0d88b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_link_operations.py +++ /dev/null @@ -1,660 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index ab256a384624..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_group_operations.py +++ /dev/null @@ -1,537 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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}/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])?$", - ), - "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_check_entity_exists_request( - resource_group_name: str, service_name: str, product_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-05-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}/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])?$", - ), - "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"), - } - - _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, product_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-05-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}/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])?$", - ), - "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"), - } - - _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, product_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-05-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}/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])?$", - ), - "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"), - } - - _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 ProductGroupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`product_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_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.GroupContract"]: - """Lists the collection of developer groups associated with 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| name | - filter | ge, le, eq, ne, gt, lt | |
| displayName | filter | eq, ne | |
| - description | 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 - :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 = { - 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("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 check_entity_exists( - self, resource_group_name: str, service_name: str, product_id: str, group_id: str, **kwargs: Any - ) -> bool: - """Checks that Group entity specified by identifier is associated with the Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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 = { - 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, - product_id=product_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 [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 - return 200 <= response.status_code <= 299 - - @distributed_trace - def create_or_update( - self, resource_group_name: str, service_name: str, product_id: str, group_id: str, **kwargs: Any - ) -> _models.GroupContract: - """Adds the association between the specified developer group with 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_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 = { - 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_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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, 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("GroupContract", 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_id: str, **kwargs: Any - ) -> None: - """Deletes the association between the specified group and 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_id: Group identifier. Must be unique in the current API Management service - instance. Required. - :type group_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_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, 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_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py deleted file mode 100644 index 9ad1a5d404a7..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_operations.py +++ /dev/null @@ -1,1149 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-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}", - ) # 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 - _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, 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-05-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}", - ) # 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 - _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, - 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-05-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}", - ) # 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 - _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, 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-05-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}", - ) # 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 - _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, - 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-05-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}", - ) # 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 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) - - -def build_list_by_tags_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - include_not_tagged_products: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags", - ) # 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) - if include_not_tagged_products is not None: - _params["includeNotTaggedProducts"] = _SERIALIZER.query( - "include_not_tagged_products", include_not_tagged_products, "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) - - -class ProductOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - 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 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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 - - @distributed_trace - def list_by_tags( - self, - resource_group_name: str, - service_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - include_not_tagged_products: Optional[bool] = None, - **kwargs: Any - ) -> Iterable["_models.TagResourceContract"]: - """Lists a collection of products associated with tags. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| 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 | 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 include_not_tagged_products: Include not tagged Products. Default value is None. - :type include_not_tagged_products: bool - :return: An iterator like instance of either TagResourceContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :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.TagResourceCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_tags_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - include_not_tagged_products=include_not_tagged_products, - 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("TagResourceCollection", 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/_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py deleted file mode 100644 index bca90f67145f..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_policy_operations.py +++ /dev/null @@ -1,779 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, **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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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 ProductPolicyOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, product_id: str, **kwargs: Any - ) -> 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. - 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 - :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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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 = { - 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, - 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/_product_subscriptions_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py deleted file mode 100644 index c3dccea1f606..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_subscriptions_operations.py +++ /dev/null @@ -1,228 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-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}/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])?$", - ), - "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) - - -class ProductSubscriptionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`product_subscriptions` 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, - product_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.SubscriptionContract"]: - """Lists the collection of subscriptions 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 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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("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) 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 deleted file mode 100644 index cbd0754f7c87..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wiki_operations.py +++ /dev/null @@ -1,783 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_entity_tag_request( - resource_group_name: str, service_name: 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-05-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}/wikis/default", - ) # 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 - _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, 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-05-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}/wikis/default", - ) # 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 - _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, - 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-05-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}/wikis/default", - ) # 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 - _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, 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-05-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}/wikis/default", - ) # 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 - _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, 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-05-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}/wikis/default", - ) # 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 - _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 ProductWikiOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`product_wiki` 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_entity_tag(self, resource_group_name: str, service_name: str, product_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the Wiki for a 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 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 = { - 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, - 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, product_id: str, **kwargs: Any) -> _models.WikiContract: - """Gets the details of the Wiki for a 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_id: str - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("WikiContract", 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, - parameters: _models.WikiContract, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_id: str - :param parameters: Create parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiContract - :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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - parameters: Union[_models.WikiContract, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.WikiContract: - """Creates a new Wiki for a Product 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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_id: str - :param parameters: Create parameters. Is either a WikiContract type or a IO[bytes] type. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiContract 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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = 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, "WikiContract") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("WikiContract", 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, - product_id: str, - if_match: str, - parameters: _models.WikiUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki for a 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 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: Wiki Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki for a 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 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: Wiki 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: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - product_id: str, - if_match: str, - parameters: Union[_models.WikiUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.WikiContract: - """Updates the details of the Wiki for a 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 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: Wiki Update parameters. Is either a WikiUpdateContract type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.WikiUpdateContract or IO[bytes] - :return: WikiContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.WikiContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.WikiContract] = 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, "WikiUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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("WikiContract", 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, product_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes the specified Wiki from 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 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 = { - 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, - 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/_product_wikis_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wikis_operations.py deleted file mode 100644 index e5f0bea53e4a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_wikis_operations.py +++ /dev/null @@ -1,219 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-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}/wikis", - ) # 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) - - -class ProductWikisOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`product_wikis` 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, - product_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.WikiContract"]: - """Gets the details of the Wiki for a 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 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 |
|-------------|-------------|-------------|-------------|
| name | - filter | eq | contains |
. 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 WikiContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.WikiContract] - :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.WikiCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("WikiCollection", 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/_quota_by_counter_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py deleted file mode 100644 index 351e720998ed..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_counter_keys_operations.py +++ /dev/null @@ -1,366 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, quota_counter_key: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}", - ) # 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])?$", - ), - "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "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_update_request( - resource_group_name: str, service_name: str, quota_counter_key: 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-05-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}/quotas/{quotaCounterKey}", - ) # 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])?$", - ), - "quotaCounterKey": _SERIALIZER.url("quota_counter_key", quota_counter_key, "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 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) - - -class QuotaByCounterKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`quota_by_counter_keys` 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, quota_counter_key: str, **kwargs: Any - ) -> _models.QuotaCounterCollection: - """Lists a collection of current quota counter periods associated with the counter-key configured - in the policy on the specified service instance. The api does not support paging yet. - - .. seealso:: - - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-product-with-rules#a-namepolicies-ato-configure-call-rate-limit-and-quota-policies - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :return: QuotaCounterCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.QuotaCounterCollection] = kwargs.pop("cls", None) - - _request = build_list_by_service_request( - resource_group_name=resource_group_name, - service_name=service_name, - quota_counter_key=quota_counter_key, - 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("QuotaCounterCollection", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - parameters: _models.QuotaCounterValueUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.QuotaCounterCollection: - """Updates all the quota counter values specified with the existing quota counter key to a value - in the specified service instance. This should be used for reset of the quota counter values. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param parameters: The value of the quota counter to be applied to all quota counter periods. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: QuotaCounterCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.QuotaCounterCollection: - """Updates all the quota counter values specified with the existing quota counter key to a value - in the specified service instance. This should be used for reset of the quota counter values. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param parameters: The value of the quota counter to be applied to all quota counter periods. - 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: QuotaCounterCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - parameters: Union[_models.QuotaCounterValueUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.QuotaCounterCollection: - """Updates all the quota counter values specified with the existing quota counter key to a value - in the specified service instance. This should be used for reset of the quota counter values. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param parameters: The value of the quota counter to be applied to all quota counter periods. - Is either a QuotaCounterValueUpdateContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or IO[bytes] - :return: QuotaCounterCollection or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.QuotaCounterCollection] = 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, "QuotaCounterValueUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - quota_counter_key=quota_counter_key, - 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("QuotaCounterCollection", 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/_quota_by_period_keys_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py deleted file mode 100644 index 9bf480a9cd02..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_quota_by_period_keys_operations.py +++ /dev/null @@ -1,388 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - quota_counter_key: str, - quota_period_key: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}", - ) # 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])?$", - ), - "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"), - } - - _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_update_request( - resource_group_name: str, - service_name: str, - quota_counter_key: str, - quota_period_key: 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-05-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}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}", - ) # 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])?$", - ), - "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"), - } - - _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) - - -class QuotaByPeriodKeysOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`quota_by_period_keys` 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, quota_counter_key: str, quota_period_key: str, **kwargs: Any - ) -> _models.QuotaCounterContract: - """Gets the value of the quota counter associated with the counter-key in the policy for the - specific period in service instance. - - .. seealso:: - - - https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-product-with-rules#a-namepolicies-ato-configure-call-rate-limit-and-quota-policies - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param quota_period_key: Quota period key identifier. Required. - :type quota_period_key: str - :return: QuotaCounterContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.QuotaCounterContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - quota_counter_key=quota_counter_key, - quota_period_key=quota_period_key, - 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("QuotaCounterContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - quota_period_key: str, - parameters: _models.QuotaCounterValueUpdateContract, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.QuotaCounterContract: - """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param quota_period_key: Quota period key identifier. Required. - :type quota_period_key: str - :param parameters: The value of the Quota counter to be applied on the specified period. - Required. - :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: QuotaCounterContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - quota_period_key: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.QuotaCounterContract: - """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param quota_period_key: Quota period key identifier. Required. - :type quota_period_key: str - :param parameters: The value of the Quota counter to be applied on the specified period. - 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: QuotaCounterContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - quota_counter_key: str, - quota_period_key: str, - parameters: Union[_models.QuotaCounterValueUpdateContract, IO[bytes]], - **kwargs: Any - ) -> _models.QuotaCounterContract: - """Updates an existing quota counter value in the specified 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 quota_counter_key: Quota counter key identifier.This is the result of expression defined - in counter-key attribute of the quota-by-key policy.For Example, if you specify - counter-key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined - as counter-key="@("b"+"a")" then it will be accessible by "ba" key. Required. - :type quota_counter_key: str - :param quota_period_key: Quota period key identifier. Required. - :type quota_period_key: str - :param parameters: The value of the Quota counter to be applied on the specified period. Is - either a QuotaCounterValueUpdateContract type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.QuotaCounterValueUpdateContract or IO[bytes] - :return: QuotaCounterContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.QuotaCounterContract] = 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, "QuotaCounterValueUpdateContract") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - quota_counter_key=quota_counter_key, - quota_period_key=quota_period_key, - 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("QuotaCounterContract", 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/_region_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py deleted file mode 100644 index 42be5259ff8b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_region_operations.py +++ /dev/null @@ -1,182 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions", - ) # 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 RegionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`region` 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.RegionContract"]: - """Lists all azure regions in which the service exists. - - :param resource_group_name: The name of the resource group. The name 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 RegionContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.RegionContract] - :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.RegionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("RegionListResult", 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/_reports_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py deleted file mode 100644 index 811f7c768f26..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_reports_operations.py +++ /dev/null @@ -1,1405 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import datetime -import sys -from typing import Any, Callable, Dict, Iterable, Optional, 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 -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, - subscription_id: str, - *, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi", - ) # 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["$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 orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "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_list_by_user_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser", - ) # 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["$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 orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "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_list_by_operation_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation", - ) # 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["$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 orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "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_list_by_product_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct", - ) # 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["$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 orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "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_list_by_geo_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - filter: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo", - ) # 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["$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_list_by_subscription_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription", - ) # 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["$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 orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "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_list_by_time_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - filter: str, - interval: datetime.timedelta, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime", - ) # 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["$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 orderby is not None: - _params["$orderby"] = _SERIALIZER.query("orderby", orderby, "str") - _params["interval"] = _SERIALIZER.query("interval", interval, "duration") - _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_by_request_request( - resource_group_name: str, - service_name: str, - subscription_id: str, - *, - filter: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest", - ) # 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["$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 ReportsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`reports` 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, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ReportRecordContract"]: - """Lists report records by 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 filter: The filter to apply on the operation. Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_user( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ReportRecordContract"]: - """Lists report records by 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| displayName | select, orderBy | | |
| userId | - select, filter | eq | |
| apiRegion | filter | eq | |
| productId | filter | - eq | |
| subscriptionId | filter | eq | |
| apiId | filter | eq | | -
| operationId | filter | eq | |
| callCountSuccess | select, orderBy | | - |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, - orderBy | | |
| callCountOther | select, orderBy | | |
| - callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | select | | | -
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | -
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. - Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_user_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_operation( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ReportRecordContract"]: - """Lists report records by API Operations. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | - filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | -
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| - operationId | select, filter | eq | |
| callCountSuccess | select, orderBy | | - |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, - orderBy | | |
| callCountOther | select, orderBy | | |
| - callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | select | | | -
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | -
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. - Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_product( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ReportRecordContract"]: - """Lists report records by 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | - filter | eq | |
| userId | filter | eq | |
| productId | select, filter | eq - | |
| subscriptionId | filter | eq | |
| callCountSuccess | select, orderBy | - | |
| callCountBlocked | select, orderBy | | |
| callCountFailed | - select, orderBy | | |
| callCountOther | select, orderBy | | |
| - callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | select | | | -
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | -
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. - Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_geo( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.ReportRecordContract"]: - """Lists report records by geography. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| country | select | | |
| region | select | | - |
| zip | select | | |
| apiRegion | filter | eq | |
| userId | - filter | eq | |
| productId | filter | eq | |
| subscriptionId | filter | eq - | |
| apiId | filter | eq | |
| operationId | filter | eq | |
| - callCountSuccess | select | | |
| callCountBlocked | select | | |
| - callCountFailed | select | | |
| callCountOther | select | | |
| - bandwidth | select, orderBy | | |
| cacheHitsCount | select | | |
| - cacheMissCount | select | | |
| apiTimeAvg | select | | |
| - apiTimeMin | select | | |
| apiTimeMax | select | | |
| - serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| - serviceTimeMax | select | | |
. Required. - :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 ReportRecordContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_geo_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("ReportCollection", 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_by_subscription( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ReportRecordContract"]: - """Lists report records by 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | - filter | eq | |
| userId | select, filter | eq | |
| productId | select, - filter | eq | |
| subscriptionId | select, filter | eq | |
| callCountSuccess - | select, orderBy | | |
| callCountBlocked | select, orderBy | | |
| - callCountFailed | select, orderBy | | |
| callCountOther | select, orderBy | | - |
| callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | - | |
| cacheHitsCount | select | | |
| cacheMissCount | select | | - |
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | -
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. - Required. - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_subscription_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_time( - self, - resource_group_name: str, - service_name: str, - filter: str, - interval: datetime.timedelta, - top: Optional[int] = None, - skip: Optional[int] = None, - orderby: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.ReportRecordContract"]: - """Lists report records by Time. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| timestamp | - filter, select | ge, le | |
| interval | select | | |
| apiRegion | - filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | -
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| - operationId | filter | eq | |
| callCountSuccess | select | | |
| - callCountBlocked | select | | |
| callCountFailed | select | | |
| - callCountOther | select | | |
| bandwidth | select, orderBy | | |
| - cacheHitsCount | select | | |
| cacheMissCount | select | | |
| - apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | - select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | - select | | |
| serviceTimeMax | select | | |
. Required. - :type filter: str - :param interval: By time interval. Interval must be multiple of 15 minutes and may not be zero. - The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This - code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new - TimeSpan(hours, minutes, seconds)). Required. - :type interval: ~datetime.timedelta - :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 orderby: OData order by query option. Default value is None. - :type orderby: str - :return: An iterator like instance of either ReportRecordContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :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.ReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_time_request( - resource_group_name=resource_group_name, - service_name=service_name, - subscription_id=self._config.subscription_id, - filter=filter, - interval=interval, - top=top, - skip=skip, - orderby=orderby, - 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("ReportCollection", 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_by_request( - self, - resource_group_name: str, - service_name: str, - filter: str, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.RequestReportRecordContract"]: - """Lists report records by Request. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| timestamp | - filter | ge, le | |
| apiId | filter | eq | |
| operationId | filter | eq | - |
| productId | filter | eq | |
| userId | filter | eq | |
| apiRegion | - filter | eq | |
| subscriptionId | filter | eq | |
. Required. - :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 RequestReportRecordContract or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.RequestReportRecordContract] - :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.RequestReportCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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_request_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("RequestReportCollection", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return 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/_sign_in_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py deleted file mode 100644 index 66f74dad7b5b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_in_settings_operations.py +++ /dev/null @@ -1,623 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_entity_tag_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin", - ) # 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="HEAD", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin", - ) # 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) - - -def build_update_request( - resource_group_name: str, service_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-05-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}/portalsettings/signin", - ) # 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["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_create_or_update_request( - resource_group_name: str, service_name: 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-05-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}/portalsettings/signin", - ) # 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 - 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) - - -class SignInSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`sign_in_settings` 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_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the SignInSettings. - - :param resource_group_name: The name of the resource group. The name 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: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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, **kwargs: Any) -> _models.PortalSigninSettings: - """Get Sign In Settings for the Portal. - - :param resource_group_name: The name of the resource group. The name 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: PortalSigninSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSigninSettings] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("PortalSigninSettings", 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, - if_match: str, - parameters: _models.PortalSigninSettings, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-In settings. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-In settings. 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: Union[_models.PortalSigninSettings, IO[bytes]], - **kwargs: Any - ) -> None: - """Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-In settings. Is either a PortalSigninSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "PortalSigninSettings") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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 [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 create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: _models.PortalSigninSettings, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalSigninSettings: - """Create or Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :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: PortalSigninSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalSigninSettings: - """Create or Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is 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: 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: PortalSigninSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.PortalSigninSettings, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.PortalSigninSettings: - """Create or Update Sign-In settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is either a PortalSigninSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSigninSettings 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: PortalSigninSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSigninSettings] = 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, "PortalSigninSettings") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - deserialized = self._deserialize("PortalSigninSettings", 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/_sign_up_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py deleted file mode 100644 index ddbbfacd812d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_sign_up_settings_operations.py +++ /dev/null @@ -1,623 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_entity_tag_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup", - ) # 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="HEAD", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup", - ) # 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) - - -def build_update_request( - resource_group_name: str, service_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-05-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}/portalsettings/signup", - ) # 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["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_create_or_update_request( - resource_group_name: str, service_name: 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-05-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}/portalsettings/signup", - ) # 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 - 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) - - -class SignUpSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`sign_up_settings` 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_entity_tag(self, resource_group_name: str, service_name: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the SignUpSettings. - - :param resource_group_name: The name of the resource group. The name 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: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - 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, **kwargs: Any) -> _models.PortalSignupSettings: - """Get Sign Up Settings for the Portal. - - :param resource_group_name: The name of the resource group. The name 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: PortalSignupSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSignupSettings] = kwargs.pop("cls", None) - - _request = build_get_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) - - _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("PortalSignupSettings", 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, - if_match: str, - parameters: _models.PortalSignupSettings, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-Up settings. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> None: - """Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-Up settings. 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: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - if_match: str, - parameters: Union[_models.PortalSignupSettings, IO[bytes]], - **kwargs: Any - ) -> None: - """Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_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 - :param parameters: Update Sign-Up settings. Is either a PortalSignupSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings or IO[bytes] - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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[None] = 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, "PortalSignupSettings") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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 [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 create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: _models.PortalSignupSettings, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalSignupSettings: - """Create or Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :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: PortalSignupSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: IO[bytes], - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PortalSignupSettings: - """Create or Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is 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: 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: PortalSignupSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - parameters: Union[_models.PortalSignupSettings, IO[bytes]], - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.PortalSignupSettings: - """Create or Update Sign-Up settings. - - :param resource_group_name: The name of the resource group. The name is 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: Create or update parameters. Is either a PortalSignupSettings type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.PortalSignupSettings 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: PortalSignupSettings or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.PortalSignupSettings] = 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, "PortalSignupSettings") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - 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) - - deserialized = self._deserialize("PortalSignupSettings", 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/_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py deleted file mode 100644 index 082fcce0c114..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_subscription_operations.py +++ /dev/null @@ -1,1348 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, - 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-05-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}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 SubscriptionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.SubscriptionContract"]: - """Lists all subscriptions 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, sid: str, **kwargs: Any - ) -> None: - """Regenerates primary key of existing subscription 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 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 = { - 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, - 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, sid: str, **kwargs: Any - ) -> None: - """Regenerates secondary key of existing subscription 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 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 = { - 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, - 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, 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 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 = { - 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, - 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/_tag_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_api_link_operations.py deleted file mode 100644 index 567d57fe488b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_api_link_operations.py +++ /dev/null @@ -1,644 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 41db4aefefb3..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operation_link_operations.py +++ /dev/null @@ -1,660 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 7d508bc93d80..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_operations.py +++ /dev/null @@ -1,2785 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - api_id: str, - operation_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/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])?$", - ), - "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 - 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_state_by_operation_request( # pylint: disable=name-too-long - resource_group_name: str, - service_name: str, - api_id: str, - operation_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/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])?$", - ), - "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"), - } - - _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_by_operation_request( - resource_group_name: str, - service_name: str, - api_id: str, - operation_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/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])?$", - ), - "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"), - } - - _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_assign_to_operation_request( - resource_group_name: str, - service_name: str, - api_id: str, - operation_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/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])?$", - ), - "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"), - } - - _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_detach_from_operation_request( - resource_group_name: str, - service_name: str, - api_id: str, - operation_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/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])?$", - ), - "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"), - } - - _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_api_request( - resource_group_name: str, - service_name: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/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])?$", - ), - "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_state_by_api_request( - resource_group_name: str, service_name: str, api_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/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])?$", - ), - "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"), - } - - _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_by_api_request( - resource_group_name: str, service_name: str, api_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/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])?$", - ), - "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"), - } - - _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_assign_to_api_request( - resource_group_name: str, service_name: str, api_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/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])?$", - ), - "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"), - } - - _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_detach_from_api_request( - resource_group_name: str, service_name: str, api_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/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])?$", - ), - "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"), - } - - _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_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-05-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}/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])?$", - ), - "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_entity_state_by_product_request( # pylint: disable=name-too-long - resource_group_name: str, service_name: str, product_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-05-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}/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])?$", - ), - "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"), - } - - _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_by_product_request( - resource_group_name: str, service_name: str, product_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-05-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}/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])?$", - ), - "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"), - } - - _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_assign_to_product_request( - resource_group_name: str, service_name: str, product_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-05-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}/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])?$", - ), - "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"), - } - - _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_detach_from_product_request( - resource_group_name: str, service_name: str, product_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-05-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}/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])?$", - ), - "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"), - } - - _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_service_request( - resource_group_name: str, - service_name: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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, 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-05-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}", - ) # 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 - _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, 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-05-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}", - ) # 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 - _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, - 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-05-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}", - ) # 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 - _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, 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-05-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}", - ) # 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 - _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, 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-05-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}", - ) # 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 - _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 TagOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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_operation( - self, - resource_group_name: str, - service_name: str, - api_id: str, - operation_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.TagContract"]: - """Lists all Tags associated with the 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 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| 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 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 = { - 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, - api_id=api_id, - operation_id=operation_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("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_by_operation( - self, resource_group_name: str, service_name: str, api_id: str, operation_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 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 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 = { - 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_by_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - operation_id=operation_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_by_operation( - self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Get tag associated with the 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 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 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 = { - 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_by_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - operation_id=operation_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 - - @distributed_trace - def assign_to_operation( - self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Assign tag to the 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 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 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 = { - 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_assign_to_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - operation_id=operation_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, 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("TagContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def detach_from_operation( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, service_name: str, api_id: str, operation_id: str, tag_id: str, **kwargs: Any - ) -> None: - """Detach the tag from the 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. - Required. - :type tag_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_detach_from_operation_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - operation_id=operation_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, 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_by_api( - self, - resource_group_name: str, - service_name: str, - api_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.TagContract"]: - """Lists all Tags associated with 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 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 |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| 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 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 = { - 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, - 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("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_by_api( - self, resource_group_name: str, service_name: str, api_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 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 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 = { - 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_by_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_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_by_api( - self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Get tag associated with 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 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 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 = { - 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_by_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_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 - - @distributed_trace - def assign_to_api( - self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Assign tag to 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 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 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 = { - 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_assign_to_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_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, 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 - - @distributed_trace - def detach_from_api( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, service_name: str, api_id: str, tag_id: str, **kwargs: Any - ) -> None: - """Detach the tag from 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 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. - Required. - :type tag_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_detach_from_api_request( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_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, 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_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.TagContract"]: - """Lists all Tags associated with 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 filter: | Field | Usage | Supported operators | Supported - functions |
|-------------|-------------|-------------|-------------|
| displayName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| 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 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 = { - 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("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_by_product( - self, resource_group_name: str, service_name: str, product_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 product_id: Product identifier. Must be unique in the current API Management service - instance. Required. - :type product_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 = { - 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_by_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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_by_product( - self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Get tag associated with 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 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 = { - 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_by_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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 - - @distributed_trace - def assign_to_product( - self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any - ) -> _models.TagContract: - """Assign tag to 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 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 = { - 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_assign_to_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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, 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("TagContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def detach_from_product( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, service_name: str, product_id: str, tag_id: str, **kwargs: Any - ) -> None: - """Detach the tag from 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. - Required. - :type tag_id: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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_detach_from_product_request( - resource_group_name=resource_group_name, - service_name=service_name, - product_id=product_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, 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_by_service( - self, - resource_group_name: str, - service_name: 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 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 |
|-------------|-------------|-------------|-------------|
| 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 = { - 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, - 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, 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 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 = { - 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, - 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, 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, - 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 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, - 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 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, - 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 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 = { - 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, - 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, tag_id: str, if_match: str, **kwargs: Any - ) -> None: - """Deletes specific tag 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 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 = { - 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, - 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/_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_product_link_operations.py deleted file mode 100644 index c73f46e9148f..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_product_link_operations.py +++ /dev/null @@ -1,645 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 052f34d43ac4..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tag_resource_operations.py +++ /dev/null @@ -1,224 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources", - ) # 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) - - -class TagResourceOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`tag_resource` 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.TagResourceContract"]: - """Lists a collection of resources associated with tags. - - :param resource_group_name: The name of the resource group. The name is 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 |
|-------------|-------------|-------------|-------------|
| aid | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| - displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| path | 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 |
| method | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| urlTemplate | 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 | |
| isCurrent - | 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 TagResourceContract or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :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.TagResourceCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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("TagResourceCollection", 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/_tenant_access_git_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py deleted file mode 100644 index 38814e21598e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_git_operations.py +++ /dev/null @@ -1,262 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_regenerate_primary_key_request( - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/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])?$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "accessName": _SERIALIZER.url("access_name", access_name, "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, - access_name: Union[str, _models.AccessIdName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/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])?$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "accessName": _SERIALIZER.url("access_name", access_name, "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 TenantAccessGitOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`tenant_access_git` 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 regenerate_primary_key( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> None: - """Regenerate primary access key for GIT. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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 [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, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> None: - """Regenerate secondary access key for GIT. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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 [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/_tenant_access_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py deleted file mode 100644 index d5c40213fece..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_access_operations.py +++ /dev/null @@ -1,1148 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, **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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant", - ) # 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") - _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, - access_name: Union[str, _models.AccessIdName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", - ) # 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"), - "accessName": _SERIALIZER.url("access_name", access_name, "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, - access_name: Union[str, _models.AccessIdName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}", - ) # 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"), - "accessName": _SERIALIZER.url("access_name", access_name, "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_request( - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - 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-05-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}/tenant/{accessName}", - ) # 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])?$", - ), - "accessName": _SERIALIZER.url("access_name", access_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["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, - access_name: Union[str, _models.AccessIdName], - 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-05-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}/tenant/{accessName}", - ) # 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])?$", - ), - "accessName": _SERIALIZER.url("access_name", access_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["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_regenerate_primary_key_request( - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/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])?$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "accessName": _SERIALIZER.url("access_name", access_name, "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, - access_name: Union[str, _models.AccessIdName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/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])?$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "accessName": _SERIALIZER.url("access_name", access_name, "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, - access_name: Union[str, _models.AccessIdName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/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])?$", - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "accessName": _SERIALIZER.url("access_name", access_name, "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 TenantAccessOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`tenant_access` 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, **kwargs: Any - ) -> Iterable["_models.AccessInformationContract"]: - """Returns list of access infos - for Git and Management endpoints. - - :param resource_group_name: The name of the resource group. The name is 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: Not used. Default value is None. - :type filter: str - :return: An iterator like instance of either AccessInformationContract or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AccessInformationContract] - :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.AccessInformationCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("AccessInformationCollection", 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, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> bool: - """Tenant access metadata. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: bool or the result of cls(response) - :rtype: bool - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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) - - 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, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> _models.AccessInformationContract: - """Get tenant access information details without secrets. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AccessInformationContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - access_name=access_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AccessInformationContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def create( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: _models.AccessInformationCreateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. 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: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: Union[_models.AccessInformationCreateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. Is either a - AccessInformationCreateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationCreateParameters or - IO[bytes] - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AccessInformationContract] = 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, "AccessInformationCreateParameters") - - _request = build_create_request( - resource_group_name=resource_group_name, - service_name=service_name, - access_name=access_name, - 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("AccessInformationContract", 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, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: _models.AccessInformationUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. 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: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - access_name: Union[str, _models.AccessIdName], - if_match: str, - parameters: Union[_models.AccessInformationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.AccessInformationContract: - """Update tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :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: Parameters supplied to retrieve the Tenant Access Information. Is either a - AccessInformationUpdateParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.AccessInformationUpdateParameters or - IO[bytes] - :return: AccessInformationContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AccessInformationContract] = 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, "AccessInformationUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - access_name=access_name, - 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("AccessInformationContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def regenerate_primary_key( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, service_name: str, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> None: - """Regenerate primary access key. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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 [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, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> None: - """Regenerate secondary access key. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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, - access_name=access_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 [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, access_name: Union[str, _models.AccessIdName], **kwargs: Any - ) -> _models.AccessInformationSecretsContract: - """Get tenant access information 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 access_name: The identifier of the Access configuration. Known values are: "access" and - "gitAccess". Required. - :type access_name: str or ~azure.mgmt.apimanagement.models.AccessIdName - :return: AccessInformationSecretsContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationSecretsContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.AccessInformationSecretsContract] = kwargs.pop("cls", None) - - _request = build_list_secrets_request( - resource_group_name=resource_group_name, - service_name=service_name, - access_name=access_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) - - response_headers = {} - response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - - deserialized = self._deserialize("AccessInformationSecretsContract", 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/_tenant_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py deleted file mode 100644 index d9fa3a8e41d0..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_configuration_operations.py +++ /dev/null @@ -1,992 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, Iterator, Optional, TypeVar, Union, cast, overload - -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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_deploy_request( - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - 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-05-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}/tenant/{configurationName}/deploy", - ) # 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"), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "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_save_request( - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - 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-05-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}/tenant/{configurationName}/save", - ) # 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"), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "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_validate_request( - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - 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-05-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}/tenant/{configurationName}/validate", - ) # 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"), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "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_get_sync_state_request( - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState", - ) # 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"), - "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "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 TenantConfigurationOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`tenant_configuration` 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 _deploy_initial( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, "DeployConfigurationParameters") - - _request = build_deploy_request( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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_deploy( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: _models.DeployConfigurationParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationResultContract]: - """This operation applies changes from the specified Git branch to the configuration database. - This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-deploy-any-service-configuration-changes-to-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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Deploy Configuration parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters - :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 OperationResultContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_deploy( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationResultContract]: - """This operation applies changes from the specified Git branch to the configuration database. - This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-deploy-any-service-configuration-changes-to-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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Deploy Configuration 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 OperationResultContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_deploy( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OperationResultContract]: - """This operation applies changes from the specified Git branch to the configuration database. - This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-deploy-any-service-configuration-changes-to-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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Deploy Configuration parameters. Is either a DeployConfigurationParameters - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or IO[bytes] - :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 = case_insensitive_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.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._deploy_initial( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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("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 - ) - - def _save_initial( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.SaveConfigurationParameter, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, "SaveConfigurationParameter") - - _request = build_save_request( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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_save( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: _models.SaveConfigurationParameter, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationResultContract]: - """This operation creates a commit with the current configuration snapshot to the specified branch - in the repository. This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-save-the-service-configuration-to-the-git-repository - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Save Configuration parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter - :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 OperationResultContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_save( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationResultContract]: - """This operation creates a commit with the current configuration snapshot to the specified branch - in the repository. This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-save-the-service-configuration-to-the-git-repository - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Save Configuration 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 OperationResultContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_save( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.SaveConfigurationParameter, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OperationResultContract]: - """This operation creates a commit with the current configuration snapshot to the specified branch - in the repository. This is a long running operation and could take several minutes to complete. - - .. seealso:: - - - https://azure.microsoft.com/en-us/documentation/articles/api-management-configuration-repository-git/#to-save-the-service-configuration-to-the-git-repository - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Save Configuration parameters. Is either a SaveConfigurationParameter type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.SaveConfigurationParameter or IO[bytes] - :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 = case_insensitive_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.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._save_initial( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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("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 - ) - - def _validate_initial( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, "DeployConfigurationParameters") - - _request = build_validate_request( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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_validate( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: _models.DeployConfigurationParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationResultContract]: - """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Validate Configuration parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters - :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 OperationResultContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_validate( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.OperationResultContract]: - """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Validate Configuration 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 OperationResultContract or the result of - cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_validate( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - parameters: Union[_models.DeployConfigurationParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.OperationResultContract]: - """This operation validates the changes in the specified Git branch. This is a 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 configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :param parameters: Validate Configuration parameters. Is either a DeployConfigurationParameters - type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.DeployConfigurationParameters or IO[bytes] - :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 = case_insensitive_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.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._validate_initial( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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("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 - ) - - @distributed_trace - def get_sync_state( - self, - resource_group_name: str, - service_name: str, - configuration_name: Union[str, _models.ConfigurationIdName], - **kwargs: Any - ) -> _models.TenantConfigurationSyncStateContract: - """Gets the status of the most recent synchronization between the configuration database and the - Git repository. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param configuration_name: The identifier of the Git Configuration Operation. "configuration" - Required. - :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName - :return: TenantConfigurationSyncStateContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.TenantConfigurationSyncStateContract] = kwargs.pop("cls", None) - - _request = build_get_sync_state_request( - resource_group_name=resource_group_name, - service_name=service_name, - configuration_name=configuration_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("TenantConfigurationSyncStateContract", 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/_tenant_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py deleted file mode 100644 index b8bc7c671784..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_tenant_settings_operations.py +++ /dev/null @@ -1,301 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, **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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings", - ) # 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") - _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, - settings_type: Union[str, _models.SettingsTypeName], - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}", - ) # 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"), - "settingsType": _SERIALIZER.url("settings_type", settings_type, "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 TenantSettingsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`tenant_settings` 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, **kwargs: Any - ) -> Iterable["_models.TenantSettingsContract"]: - """Public settings. - - :param resource_group_name: The name of the resource group. The name is 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: Not used. Default value is None. - :type filter: str - :return: An iterator like instance of either TenantSettingsContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.TenantSettingsContract] - :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.TenantSettingsCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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("TenantSettingsCollection", 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, - settings_type: Union[str, _models.SettingsTypeName], - **kwargs: Any - ) -> _models.TenantSettingsContract: - """Get tenant settings. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param service_name: The name of the API Management service. Required. - :type service_name: str - :param settings_type: The identifier of the settings. "public" Required. - :type settings_type: str or ~azure.mgmt.apimanagement.models.SettingsTypeName - :return: TenantSettingsContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.TenantSettingsContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.TenantSettingsContract] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - service_name=service_name, - settings_type=settings_type, - 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("TenantSettingsContract", 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/_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py deleted file mode 100644 index 4e3daf5b39f5..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py +++ /dev/null @@ -1,173 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_send_request( - resource_group_name: str, - service_name: str, - user_id: str, - subscription_id: str, - *, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send", - ) # 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])?$", - ), - "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") - if app_type is not None: - _params["appType"] = _SERIALIZER.query("app_type", app_type, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class UserConfirmationPasswordOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`user_confirmation_password` 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 send( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - service_name: str, - user_id: str, - app_type: Optional[Union[str, _models.AppType]] = None, - **kwargs: Any - ) -> None: - """Sends confirmation. - - :param resource_group_name: The name of the resource group. The name is 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 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: MutableMapping = { - 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_send_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_id, - subscription_id=self._config.subscription_id, - app_type=app_type, - 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 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 deleted file mode 100644 index 241fc480f869..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_group_operations.py +++ /dev/null @@ -1,223 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - user_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/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])?$", - ), - "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 - 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 UserGroupOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`user_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( - self, - resource_group_name: str, - service_name: str, - user_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.GroupContract"]: - """Lists all user 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 user_id: User identifier. Must be unique in the current API Management service instance. - Required. - :type user_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 |
. 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 = { - 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, - user_id=user_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) 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 deleted file mode 100644 index f550dafb60ea..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_identities_operations.py +++ /dev/null @@ -1,188 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities", - ) # 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])?$", - ), - "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="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class UserIdentitiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`user_identities` 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, user_id: str, **kwargs: Any - ) -> Iterable["_models.UserIdentityContract"]: - """List of all user identities. - - :param resource_group_name: The name of the resource group. The name is 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 - :return: An iterator like instance of either UserIdentityContract or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.UserIdentityContract] - :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.UserIdentityCollection] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - 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) - - 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("UserIdentityCollection", 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/_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py deleted file mode 100644 index 0529a7bbefe0..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_operations.py +++ /dev/null @@ -1,1371 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - expand_groups: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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") - _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, 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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_get_request( - resource_group_name: str, service_name: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_create_or_update_request( - resource_group_name: str, - service_name: str, - user_id: str, - subscription_id: str, - *, - notify: Optional[bool] = None, - 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-05-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}/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])?$", - ), - "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 - if notify is not None: - _params["notify"] = _SERIALIZER.query("notify", notify, "bool") - _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, user_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-05-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}/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])?$", - ), - "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["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, - user_id: str, - subscription_id: str, - *, - if_match: str, - delete_subscriptions: Optional[bool] = None, - 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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])?$", - ), - "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 - if delete_subscriptions is not None: - _params["deleteSubscriptions"] = _SERIALIZER.query("delete_subscriptions", delete_subscriptions, "bool") - 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") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_generate_sso_url_request( - resource_group_name: str, service_name: 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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl", - ) # 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])?$", - ), - "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="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_shared_access_token_request( - resource_group_name: str, service_name: 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-05-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}/users/{userId}/token", - ) # 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])?$", - ), - "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 - 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) - - -class UserOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`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_service( - self, - resource_group_name: str, - service_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - expand_groups: Optional[bool] = None, - **kwargs: Any - ) -> Iterable["_models.UserContract"]: - """Lists a collection of registered users in the specified 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 |
|-------------|-------------|-------------|-------------|
| 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 - |
| state | filter | eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | - |
| note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| 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: Detailed Group in response. Default value is None. - :type expand_groups: bool - :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 = { - 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, - expand_groups=expand_groups, - 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 get_entity_tag(self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any) -> bool: - """Gets the entity state (Etag) version of the user 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 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 = { - 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, - 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]: - map_error(status_code=response.status_code, 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, user_id: str, **kwargs: Any) -> _models.UserContract: - """Gets the details of the user 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 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 = { - 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_get_request( - resource_group_name=resource_group_name, - service_name=service_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]: - map_error(status_code=response.status_code, 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("UserContract", 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, - user_id: str, - parameters: _models.UserCreateParameters, - notify: Optional[bool] = None, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserContract: - """Creates or Updates a 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 parameters: Create or update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters - :param notify: Send an Email notification to the User. 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 - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: IO[bytes], - notify: Optional[bool] = None, - if_match: Optional[str] = None, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserContract: - """Creates or Updates a 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 parameters: Create or update parameters. Required. - :type parameters: IO[bytes] - :param notify: Send an Email notification to the User. 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 - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: Union[_models.UserCreateParameters, IO[bytes]], - notify: Optional[bool] = None, - if_match: Optional[str] = None, - **kwargs: Any - ) -> _models.UserContract: - """Creates or Updates a 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 parameters: Create or update parameters. Is either a UserCreateParameters type or a - IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters or IO[bytes] - :param notify: Send an Email notification to the User. 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 - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.UserContract] = 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, "UserCreateParameters") - - _request = build_create_or_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_id, - subscription_id=self._config.subscription_id, - notify=notify, - 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("UserContract", 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, - user_id: str, - if_match: str, - parameters: _models.UserUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserContract: - """Updates the details of the user 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 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 parameters: Update parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - service_name: str, - user_id: str, - if_match: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserContract: - """Updates the details of the user 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 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 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: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - service_name: str, - user_id: str, - if_match: str, - parameters: Union[_models.UserUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.UserContract: - """Updates the details of the user 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 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 parameters: Update parameters. Is either a UserUpdateParameters type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserUpdateParameters or IO[bytes] - :return: UserContract or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserContract - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.UserContract] = 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, "UserUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_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("UserContract", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - def _delete_initial( - 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 - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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, - service_name=service_name, - user_id=user_id, - subscription_id=self._config.subscription_id, - if_match=if_match, - delete_subscriptions=delete_subscriptions, - notify=notify, - app_type=app_type, - 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")) - 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_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( - self, resource_group_name: str, service_name: str, user_id: str, **kwargs: Any - ) -> _models.GenerateSsoUrlResult: - """Retrieves a redirection URL containing an authentication token for signing a given user into - the developer portal. - - :param resource_group_name: The name of the resource group. The name is 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 - :return: GenerateSsoUrlResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.GenerateSsoUrlResult] = kwargs.pop("cls", None) - - _request = build_generate_sso_url_request( - resource_group_name=resource_group_name, - service_name=service_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]: - map_error(status_code=response.status_code, 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("GenerateSsoUrlResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def get_shared_access_token( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: _models.UserTokenParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserTokenResult: - """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: UserTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def get_shared_access_token( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.UserTokenResult: - """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token 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: UserTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def get_shared_access_token( - self, - resource_group_name: str, - service_name: str, - user_id: str, - parameters: Union[_models.UserTokenParameters, IO[bytes]], - **kwargs: Any - ) -> _models.UserTokenResult: - """Gets the Shared Access Authorization Token for the 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 parameters: Create Authorization Token parameters. Is either a UserTokenParameters type - or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.apimanagement.models.UserTokenParameters or IO[bytes] - :return: UserTokenResult or the result of cls(response) - :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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.UserTokenResult] = 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, "UserTokenParameters") - - _request = build_get_shared_access_token_request( - resource_group_name=resource_group_name, - service_name=service_name, - user_id=user_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("UserTokenResult", 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/_user_subscription_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py deleted file mode 100644 index 38c515377ea2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_subscription_operations.py +++ /dev/null @@ -1,338 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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, - user_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/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])?$", - ), - "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 - 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, user_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-05-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/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])?$", - ), - "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"), - } - - _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 UserSubscriptionOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.apimanagement.ApiManagementClient`'s - :attr:`user_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, - user_id: str, - filter: Optional[str] = None, - top: Optional[int] = None, - skip: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.SubscriptionContract"]: - """Lists the collection of subscriptions of the specified 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 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 |
. 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 = { - 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, - user_id=user_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( - self, resource_group_name: str, service_name: str, user_id: str, sid: str, **kwargs: Any - ) -> _models.SubscriptionContract: - """Gets the specified Subscription entity associated with a particular 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 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 = { - 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, - user_id=user_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 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 deleted file mode 100644 index 7b0c10be6b70..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_diagnostic_operations.py +++ /dev/null @@ -1,1116 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index beeeeeaa31de..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_export_operations.py +++ /dev/null @@ -1,192 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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 = { - 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 deleted file mode 100644 index 99bd7c4e0e7b..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_operations.py +++ /dev/null @@ -1,1117 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 4164da0e69ef..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operation_policy_operations.py +++ /dev/null @@ -1,883 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index c6b573222287..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_operations.py +++ /dev/null @@ -1,1146 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 25916e357d45..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_policy_operations.py +++ /dev/null @@ -1,830 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 8c29bc058f63..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_release_operations.py +++ /dev/null @@ -1,1118 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 75d22f834ba9..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_revision_operations.py +++ /dev/null @@ -1,229 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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 = { - 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 deleted file mode 100644 index 9ccd41e8c3cf..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_schema_operations.py +++ /dev/null @@ -1,946 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 226d4772ee2d..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_api_version_set_operations.py +++ /dev/null @@ -1,1048 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index fcf41f6db214..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_backend_operations.py +++ /dev/null @@ -1,1030 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 75d54ede0c37..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_certificate_operations.py +++ /dev/null @@ -1,966 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 123ee41d0148..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_diagnostic_operations.py +++ /dev/null @@ -1,1048 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 2f7834aa20f9..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_global_schema_operations.py +++ /dev/null @@ -1,889 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index e510ff629e7a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_operations.py +++ /dev/null @@ -1,1033 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 94c74c2517f8..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_group_user_operations.py +++ /dev/null @@ -1,589 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index ed6248878aaf..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_logger_operations.py +++ /dev/null @@ -1,1033 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 4700ae6e78b2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_named_value_operations.py +++ /dev/null @@ -1,1526 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 0f16f9629964..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_operations.py +++ /dev/null @@ -1,466 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 0674591371c7..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_email_operations.py +++ /dev/null @@ -1,555 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 7da503069a2f..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_notification_recipient_user_operations.py +++ /dev/null @@ -1,558 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 25a34161b3bc..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_operations.py +++ /dev/null @@ -1,965 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 3c8a5bbd2c74..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_fragment_operations.py +++ /dev/null @@ -1,1037 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 42fc78587900..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_policy_operations.py +++ /dev/null @@ -1,789 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 1191f83e911e..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_api_link_operations.py +++ /dev/null @@ -1,714 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 44ac1bc1fe42..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_group_link_operations.py +++ /dev/null @@ -1,714 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 5387ea30daed..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_operations.py +++ /dev/null @@ -1,1055 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 7327cf9761c8..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_product_policy_operations.py +++ /dev/null @@ -1,802 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index dc002c7316e2..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_subscription_operations.py +++ /dev/null @@ -1,1446 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index cfa1cf852c7a..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_api_link_operations.py +++ /dev/null @@ -1,713 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 193f64137308..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operation_link_operations.py +++ /dev/null @@ -1,714 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index ac491b9d4b86..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_operations.py +++ /dev/null @@ -1,1030 +0,0 @@ -# pylint: disable=too-many-lines -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 = { - 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 deleted file mode 100644 index 02b5093c97ff..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_workspace_tag_product_link_operations.py +++ /dev/null @@ -1,714 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license 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, 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 -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-05-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-05-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-05-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-05-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 = { - 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 = { - 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 = { - 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 = { - 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/dev_requirements.txt b/sdk/apimanagement/azure-mgmt-apimanagement/dev_requirements.txt index 0a8d1282d521..8d05a3a42632 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/dev_requirements.txt +++ b/sdk/apimanagement/azure-mgmt-apimanagement/dev_requirements.txt @@ -1,3 +1,5 @@ -e ../../../eng/tools/azure-sdk-tools ../../resources/azure-mgmt-resource aiohttp + +azure-identity \ No newline at end of file diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_managament_create_backend_with_custom_assigned_certificate_thumbprints.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_managament_create_backend_with_custom_assigned_certificate_thumbprints.py new file mode 100644 index 000000000000..339bbe93b5ee --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_managament_create_backend_with_custom_assigned_certificate_thumbprints.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) Python 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_managament_create_backend_with_custom_assigned_certificate_thumbprints.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="SUBSCRIPTION_ID", + ) + + response = client.backend.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + backend_id="cabackend", + parameters={ + "properties": { + "description": "Custom Assigned certificate Example", + "protocol": "http", + "tls": { + "serverCertificateThumbprints": ["1365083bae61ee876fc26850b825d05d3eb2e503"], + "validateCertificateChain": True, + "validateCertificateName": True, + }, + "url": "https://self-signed.badssl.com/", + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagamentCreateBackendWithCustomAssignedCertificate_Thumbprints.json +if __name__ == "__main__": + main() 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 index 033c74a77c66..0e7ed12b4f4c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.all_policies.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementAllPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 9b6135810c18..46558e5691c8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementApplyNetworkConfigurationUpdates.json +# x-ms-original-file: 2025-03-01-preview/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 5e9fc6dfc9b2..b5db8adeaae8 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.private_endpoint_connection.begin_create_or_update( @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementApproveOrRejectPrivateEndpointConnection.json +# x-ms-original-file: 2025-03-01-preview/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 392ad36b1731..0f377c4248f1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementAuthorizationServerListSecrets.json +# x-ms-original-file: 2025-03-01-preview/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 2bc4c744df38..cb597f0f76a1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.backend.reconnect( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementBackendReconnect.json +# x-ms-original-file: 2025-03-01-preview/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 bee93ac62c44..fd6ca9948834 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_backup( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementBackupWithAccessKey.json +# x-ms-original-file: 2025-03-01-preview/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 00aa476a46dc..8d0f59570dcd 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_backup( @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementBackupWithSystemManagedIdentity.json +# x-ms-original-file: 2025-03-01-preview/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 4f87208f52fc..623712f4879b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_backup( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementBackupWithUserAssignedManagedIdentity.json +# x-ms-original-file: 2025-03-01-preview/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 1141c3476622..650b6f93ed69 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.logger.create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateAILogger.json +# x-ms-original-file: 2025-03-01-preview/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 879ca378fc14..5396a56de1a0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -51,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApi.json +# x-ms-original-file: 2025-03-01-preview/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 70e02aafb016..f7361444d537 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -50,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiClone.json +# x-ms-original-file: 2025-03-01-preview/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 e2c5e3e5d003..7913f1c067c6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_diagnostic.create_or_update( @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 9d1a8e05408b..08990f034c04 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_issue.create_or_update( @@ -48,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiIssue.json +# x-ms-original-file: 2025-03-01-preview/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 2fb1cc451a86..8fc15e045f40 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_issue_attachment.create_or_update( @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiIssueAttachment.json +# x-ms-original-file: 2025-03-01-preview/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 312e185e7b42..09fcf2cf24fc 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_issue_comment.create_or_update( @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiIssueComment.json +# x-ms-original-file: 2025-03-01-preview/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 14298ca1e578..d2c4fde31e2b 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -52,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiNewVersionUsingExistingApi.json +# x-ms-original-file: 2025-03-01-preview/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 f2e95599ec05..e934a0cdeb2d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_operation.create_or_update( @@ -64,6 +64,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 d05267db3875..0d93449abc0e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_operation_policy.create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiOperationPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 5d24308f2ae1..2e2ca56ed2b7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementCreateApiOperationTag.json +# x-ms-original-file: 2025-03-01-preview/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 54f665f32bce..fa44693d5de3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_policy.create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 23eb752ce8f7..e6e72a239fe1 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_policy.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiPolicyNonXmlEncoded.json +# x-ms-original-file: 2025-03-01-preview/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 b247db36b4c2..1c137ebb8509 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_release.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiRelease.json +# x-ms-original-file: 2025-03-01-preview/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 50c3fd908986..23ef8e65e4a4 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiRevisionFromExistingApi.json +# x-ms-original-file: 2025-03-01-preview/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 efa5b67e4b59..9f6d6a33f520 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_schema.begin_create_or_update( @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiSchema.json +# x-ms-original-file: 2025-03-01-preview/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 8f52c92f715d..1537d56fab05 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementCreateApiTag.json +# x-ms-original-file: 2025-03-01-preview/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 87936793f115..672065f7f1d0 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_tag_description.create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiTagDescription.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateApiTagDescription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tool.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tool.py new file mode 100644 index 000000000000..1fd13ce82c17 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_api_tool.py @@ -0,0 +1,52 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_api_tool.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="SUBSCRIPTION_ID", + ) + + response = client.api_tool.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + api_id="github-mcp-api", + tool_id="createIssue", + parameters={ + "properties": { + "description": "This is a MCP tool to create an issue in a github repository", + "displayName": "createIssue", + "operationId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/github-rest-api/operations/createIssue", + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateApiTool.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 5a19d2f1e3bf..6f9f2c0df0a5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiUsingImportOverrideServiceUrl.json +# x-ms-original-file: 2025-03-01-preview/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 79a71c0d6fb0..f1324cc75b75 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiUsingOai3Import.json +# x-ms-original-file: 2025-03-01-preview/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 c2617c3a8671..7b210d5064e6 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiUsingOai3ImportWithTranslateRequiredQueryParametersConduct.json +# x-ms-original-file: 2025-03-01-preview/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 fd02411643ce..e895486a4cca 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiUsingSwaggerImport.json +# x-ms-original-file: 2025-03-01-preview/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 18449d15a84b..45c0a859d8c9 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiUsingWadlImport.json +# x-ms-original-file: 2025-03-01-preview/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 fdc6e92bee26..f292b2824d21 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_version_set.create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 f53c42e48aa3..291be3943bea 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_wiki.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiWiki.json +# x-ms-original-file: 2025-03-01-preview/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 83553762043e..ea3877c5d396 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiWithMultipleAuthServers.json +# x-ms-original-file: 2025-03-01-preview/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 033d2db4e013..5eb75c91a1cc 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -60,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiWithMultipleOpenIdConnectProviders.json +# x-ms-original-file: 2025-03-01-preview/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 b18f1e73a63c..04597cc51b5d 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -51,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateApiWithOpenIdConnect.json +# x-ms-original-file: 2025-03-01-preview/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 8ffa644b78a2..f259fc176097 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization.create_or_update( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateAuthorizationAADAuthCode.json +# x-ms-original-file: 2025-03-01-preview/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 5f0ae5b596a9..241c21d3f1a0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization.create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateAuthorizationAADClientCred.json +# x-ms-original-file: 2025-03-01-preview/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 a58fdd8e3f70..4a1842676ce8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_access_policy.create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateAuthorizationAccessPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 6070cb05f3b3..e9975c722f1f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_provider.create_or_update( @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateAuthorizationProviderAADAuthCode.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_auth_code_with_key_vault.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_auth_code_with_key_vault.py new file mode 100644 index 000000000000..d91f1d3372ab --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_authorization_provider_aad_auth_code_with_key_vault.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) Python 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_authorization_provider_aad_auth_code_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="SUBSCRIPTION_ID", + ) + + response = client.authorization_provider.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + authorization_provider_id="aadwithkeyvault", + parameters={ + "properties": { + "displayName": "Azure AD with Key Vault", + "identityProvider": "aad", + "oauth2": { + "grantTypes": { + "authorizationCode": { + "clientId": "53790825-fdd3-4b80-bc7a-4c3aaf25801d", + "resourceUri": "https://graph.microsoft.com", + "scopes": "User.Read.All Group.Read.All", + } + }, + "keyVault": {"secretIdentifier": "https://my.vault.azure.net/secrets/clientSecret"}, + "redirectUrl": "https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1", + }, + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateAuthorizationProviderAADAuthCodeWithKeyVault.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 ca5b2e2e63a4..a4cd85d35d59 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_provider.create_or_update( @@ -53,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json +# x-ms-original-file: 2025-03-01-preview/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 e52d01dc0539..6d921a78afb9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_provider.create_or_update( @@ -57,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json +# x-ms-original-file: 2025-03-01-preview/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 af0612f49cfc..96556484b26c 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_provider.create_or_update( @@ -54,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json +# x-ms-original-file: 2025-03-01-preview/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 751947b50d4e..606e3daa0d5e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_server.create_or_update( @@ -58,6 +58,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateAuthorizationServer.json +# x-ms-original-file: 2025-03-01-preview/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 213f41988c58..ff6792970008 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.backend.create_or_update( @@ -52,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateBackendProxyBackend.json +# x-ms-original-file: 2025-03-01-preview/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 871c19276f99..4c8afcb5d50c 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.backend.create_or_update( @@ -55,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateBackendServiceFabric.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateBackendServiceFabric.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_azure_region.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_azure_region.py new file mode 100644 index 000000000000..431c07f1e77c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_azure_region.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) Python 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_backend_with_azure_region.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="SUBSCRIPTION_ID", + ) + + response = client.backend.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + backend_id="azurebackend", + parameters={ + "properties": {"azureRegion": "northeurope", "protocol": "http", "url": "https://backendname2644/"} + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateBackendWithAzureRegion.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_carbon_aware_load_balancer.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_carbon_aware_load_balancer.py new file mode 100644 index 000000000000..1155d0d81abd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_carbon_aware_load_balancer.py @@ -0,0 +1,64 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_backend_with_carbon_aware_load_balancer.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="SUBSCRIPTION_ID", + ) + + response = client.backend.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + backend_id="carbonawareloadbalancerbackend", + parameters={ + "properties": { + "pool": { + "services": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/sustainable-backend-europe-north", + "preferredCarbonEmission": "Medium", + "priority": 1, + "weight": 1, + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/proxybackend", + "priority": 1, + "weight": 1, + }, + ] + }, + "type": "Pool", + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateBackendWithCarbonAwareLoadBalancer.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_custom_assigned_certificate_x509_names.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_custom_assigned_certificate_x509_names.py new file mode 100644 index 000000000000..a268f7d33014 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_custom_assigned_certificate_x509_names.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) Python 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_backend_with_custom_assigned_certificate_x509_names.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="SUBSCRIPTION_ID", + ) + + response = client.backend.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + backend_id="cabackend", + parameters={ + "properties": { + "description": "Custom Assigned certificate Example", + "protocol": "http", + "tls": { + "serverX509Names": [{"issuerCertificateThumbprint": None, "name": "*.badssl.com"}], + "validateCertificateChain": True, + "validateCertificateName": True, + }, + "url": "https://self-signed.badssl.com/", + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateBackendWithCustomAssignedCertificate_X509Names.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_priority_based_load_balancer.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_priority_based_load_balancer.py new file mode 100644 index 000000000000..9090a9741fb2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_priority_based_load_balancer.py @@ -0,0 +1,69 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_backend_with_priority_based_load_balancer.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="SUBSCRIPTION_ID", + ) + + response = client.backend.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + backend_id="priority-based-load-balancer", + parameters={ + "properties": { + "pool": { + "services": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/backend-1", + "priority": 1, + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/backend-2", + "priority": 1, + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/backend-3", + "priority": 2, + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/backend-4", + "priority": 2, + }, + ] + }, + "type": "Pool", + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateBackendWithPriorityBasedLoadBalancer.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_simple_load_balancer.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_simple_load_balancer.py new file mode 100644 index 000000000000..3d27c90a9884 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_simple_load_balancer.py @@ -0,0 +1,59 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_backend_with_simple_load_balancer.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="SUBSCRIPTION_ID", + ) + + response = client.backend.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + backend_id="simple-load-balancer", + parameters={ + "properties": { + "pool": { + "services": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/backend-1" + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/backend-2" + }, + ] + }, + "type": "Pool", + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateBackendWithSimpleLoadBalancer.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_weighted_load_balancer.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_weighted_load_balancer.py new file mode 100644 index 000000000000..276c13dea4fe --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_backend_with_weighted_load_balancer.py @@ -0,0 +1,61 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_backend_with_weighted_load_balancer.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="SUBSCRIPTION_ID", + ) + + response = client.backend.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + backend_id="weighted-load-balancer", + parameters={ + "properties": { + "pool": { + "services": [ + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/backend-1", + "weight": 75, + }, + { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/backend-2", + "weight": 25, + }, + ] + }, + "type": "Pool", + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateBackendWithWeightedLoadBalancer.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 9787b9f42c3b..2e35b55a6d71 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.cache.create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateCache.json +# x-ms-original-file: 2025-03-01-preview/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 4e1445e51542..57f3b075bf12 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.certificate.create_or_update( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateCertificate.json +# x-ms-original-file: 2025-03-01-preview/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 4b43656f3395..24a387828a8e 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.certificate.create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateCertificateWithKeyVault.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateCertificateWithKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_client_application.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_client_application.py new file mode 100644 index 000000000000..6d52cb98677c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_client_application.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) Python 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_client_application.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="SUBSCRIPTION_ID", + ) + + response = client.client_application.create_or_update( + resource_group_name="rg1", + service_name="apimService1", + client_application_id="testAppId", + parameters={ + "properties": { + "description": "This is just an example application", + "displayName": "Test Application", + "ownerId": "/users/userId", + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateClientApplication.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_client_application_product_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_client_application_product_link.py new file mode 100644 index 000000000000..8698ebb43f32 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_client_application_product_link.py @@ -0,0 +1,50 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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_client_application_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="SUBSCRIPTION_ID", + ) + + response = client.client_application_product_link.create( + resource_group_name="rg1", + service_name="apimService1", + client_application_id="testAppId", + client_application_product_link_id="link1", + parameters={ + "properties": { + "productId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/starter" + } + }, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateClientApplicationProductLink.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 93cc8b9df6a1..3982078a17e2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.content_type.create_or_update( @@ -86,6 +86,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateContentType.json +# x-ms-original-file: 2025-03-01-preview/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 3f69429b0e64..1481eee3f7d0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.content_item.create_or_update( @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateContentTypeContentItem.json +# x-ms-original-file: 2025-03-01-preview/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 d068912bdcc6..628db0392205 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.diagnostic.create_or_update( @@ -53,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 d32e5e55c667..eead33719251 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.documentation.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateDocumentation.json +# x-ms-original-file: 2025-03-01-preview/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 7ef137ca787e..ee039e17e237 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.logger.create_or_update( @@ -48,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateEHLogger.json +# x-ms-original-file: 2025-03-01-preview/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 12ddcc273f19..599eadbbe207 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.gateway.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGateway.json +# x-ms-original-file: 2025-03-01-preview/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 7a99eb9ffbc4..2428d93efb46 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementCreateGatewayApi.json +# x-ms-original-file: 2025-03-01-preview/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 05504611a9da..8104149e0d0e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.gateway_certificate_authority.create_or_update( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGatewayCertificateAuthority.json +# x-ms-original-file: 2025-03-01-preview/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 index dd10d4f5d6e9..91f52ab574c0 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway_config_connection.begin_create_or_update( @@ -43,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGatewayConfigConnection.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateGatewayConfigConnection.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_hostname_binding.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_hostname_binding.py new file mode 100644 index 000000000000..9aae97e63039 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_create_gateway_hostname_binding.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) Python 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_hostname_binding.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="SUBSCRIPTION_ID", + ) + + response = client.api_gateway_hostname_binding.begin_create_or_update( + resource_group_name="rg1", + gateway_name="apimGateway1", + hostname_binding_name="hb-1", + parameters={ + "properties": { + "hostname": "primary.cotoso.com", + "keyVault": { + "identityClientId": "00000000-0000-0000-0000-000000000000", + "secretId": "https://myvault.keyvault.azure.net/secrets/contosoprimarycert", + }, + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementCreateGatewayHostnameBinding.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 4b84172e52d8..145c6c9149d6 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.gateway_hostname_configuration.create_or_update( @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGatewayHostnameConfiguration.json +# x-ms-original-file: 2025-03-01-preview/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 96130eaeab0b..9648c26a7f6b 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.global_schema.begin_create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGlobalSchema1.json +# x-ms-original-file: 2025-03-01-preview/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 c5dd032b20cb..055d07bb7c7b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.global_schema.begin_create_or_update( @@ -59,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGlobalSchema2.json +# x-ms-original-file: 2025-03-01-preview/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 e2d7ea6e8069..88cadee21b8d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGraphQLApi.json +# x-ms-original-file: 2025-03-01-preview/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 e05978296b63..cb19e2c4ee77 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.graph_ql_api_resolver.create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGraphQLApiResolver.json +# x-ms-original-file: 2025-03-01-preview/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 63a705cba5eb..6d98539598ae 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.graph_ql_api_resolver_policy.create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGraphQLApiResolverPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 516119841f9d..8c7ce1bbf4d5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.group.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGroup.json +# x-ms-original-file: 2025-03-01-preview/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 53bccc9a1943..451ebb61ff20 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.group.create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGroupExternal.json +# x-ms-original-file: 2025-03-01-preview/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 dac2ad36aa41..1fb4143325e1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.group_user.create( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGroupUser.json +# x-ms-original-file: 2025-03-01-preview/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 index 1918ef9e4d5e..b2b742668b40 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -50,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateGrpcApi.json +# x-ms-original-file: 2025-03-01-preview/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 075e26066de9..f4d63cf17f89 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.identity_provider.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateIdentityProvider.json +# x-ms-original-file: 2025-03-01-preview/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 d4f9157c5bd1..460e9af9040c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -78,6 +78,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateMultiRegionServiceWithCustomHostname.json +# x-ms-original-file: 2025-03-01-preview/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 c616eb2e6fc5..d29ec368236f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.named_value.begin_create_or_update( @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 0322999ffd44..9ed32149ab5d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.named_value.begin_create_or_update( @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateNamedValueWithKeyVault.json +# x-ms-original-file: 2025-03-01-preview/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 c6d1aa864cfc..42010b3869b4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.notification.create_or_update( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateNotification.json +# x-ms-original-file: 2025-03-01-preview/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 1ab43aacf012..3e4180077f83 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.notification_recipient_email.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateNotificationRecipientEmail.json +# x-ms-original-file: 2025-03-01-preview/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 58c283e43e72..3d10e3d8fd0e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.notification_recipient_user.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateNotificationRecipientUser.json +# x-ms-original-file: 2025-03-01-preview/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 index 9a5d86a41555..6899119258fe 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateODataApi.json +# x-ms-original-file: 2025-03-01-preview/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 eab1f72140a9..68b981e1ce97 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.open_id_connect_provider.create_or_update( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateOpenIdConnectProvider.json +# x-ms-original-file: 2025-03-01-preview/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 77a81c6dab3e..e5c7af596c54 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy.create_or_update( @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreatePolicy.json +# x-ms-original-file: 2025-03-01-preview/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 be20f5536312..ce35a59a8cce 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_fragment.begin_create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreatePolicyFragment.json +# x-ms-original-file: 2025-03-01-preview/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 index 71ffd78b5925..40bdeaea55de 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_restriction.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreatePolicyRestriction.json +# x-ms-original-file: 2025-03-01-preview/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 e5428e7012bb..7c0a9989db63 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,14 +27,13 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.portal_config.create_or_update( resource_group_name="rg1", service_name="apimService1", portal_config_id="default", - if_match="*", parameters={ "properties": { "cors": {"allowedOrigins": ["https://contoso.com"]}, @@ -56,10 +55,12 @@ def main(): }, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreatePortalConfig.json +# x-ms-original-file: 2025-03-01-preview/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 bbcc7ab08f1b..bfe1e432575f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.portal_revision.begin_create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreatePortalRevision.json +# x-ms-original-file: 2025-03-01-preview/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 4f72e1e0f3b9..42eada2be3cb 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateProduct.json +# x-ms-original-file: 2025-03-01-preview/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 fb54e4655029..445d4544284b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementCreateProductApi.json +# x-ms-original-file: 2025-03-01-preview/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 index d7226ae56e8d..7208ff0aa6af 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_api_link.create_or_update( @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateProductApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 95f89384adb3..cccc990e98c1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementCreateProductGroup.json +# x-ms-original-file: 2025-03-01-preview/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 index 483b3b71ef1e..66f7d161db68 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_group_link.create_or_update( @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateProductGroupLink.json +# x-ms-original-file: 2025-03-01-preview/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 80d3f60ab7e5..23f8752feab0 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_policy.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateProductPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 366d226fb01d..fbf908ae3beb 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementCreateProductTag.json +# x-ms-original-file: 2025-03-01-preview/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 e872c463a38c..3713f1f79f3d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_wiki.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateProductWiki.json +# x-ms-original-file: 2025-03-01-preview/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 26c8c26266de..ded1fb3e2cc8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateService.json +# x-ms-original-file: 2025-03-01-preview/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 c7815204470f..dff78b6a0772 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceHavingMsi.json +# x-ms-original-file: 2025-03-01-preview/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 2d6f48d25b59..dd4280c78ddc 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -52,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceInVnetWithPublicIP.json +# x-ms-original-file: 2025-03-01-preview/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 e1777fbb411f..714f8379dd2a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceInZones.json +# x-ms-original-file: 2025-03-01-preview/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 index 95922fc1fbe6..68bedbf205d4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceSkuv2Service.json +# x-ms-original-file: 2025-03-01-preview/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 4e85bed70daf..74b9cb6994de 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -81,6 +82,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceWithCustomHostnameKeyVault.json +# x-ms-original-file: 2025-03-01-preview/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 index 04cac4cce0c8..b4abac658279 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceWithDeveloperPortal.json +# x-ms-original-file: 2025-03-01-preview/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 0e34091d37af..2d3d47d1e9f6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceWithNatGatewayEnabled.json +# x-ms-original-file: 2025-03-01-preview/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 ce1c72dec94c..da08b3ee84ff 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -53,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceWithSystemCertificates.json +# x-ms-original-file: 2025-03-01-preview/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 51edd7547697..43af4d2f7cb7 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceWithUserAssignedIdentity.json +# x-ms-original-file: 2025-03-01-preview/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 index 2c6b47351e53..030593f7117d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateServiceWithoutLegacyConfigurationApi.json +# x-ms-original-file: 2025-03-01-preview/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 ba26c35ed24f..459041e360f2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateSoapPassThroughApiUsingWsdlImport.json +# x-ms-original-file: 2025-03-01-preview/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 da28731be040..f0e7f285472f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateSoapToRestApiUsingWsdlImport.json +# x-ms-original-file: 2025-03-01-preview/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 index 8f965b15d763..065bd91bb422 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway.begin_create_or_update( @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateStandardGateway.json +# x-ms-original-file: 2025-03-01-preview/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 fc5f33e91617..e358136e9451 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.subscription.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 9a865e77b5ae..84c229de11f1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateTag.json +# x-ms-original-file: 2025-03-01-preview/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 index c896471546b9..a3ffa6549505 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag_api_link.create_or_update( @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateTagApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 3880b947e644..3af9368ce8c1 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag_operation_link.create_or_update( @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateTagOperationLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 1e435b2ccba3..5a7ac5dea361 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag_product_link.create_or_update( @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateTagProductLink.json +# x-ms-original-file: 2025-03-01-preview/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 33c545046898..ffecf33bdd46 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.email_template.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateTemplate.json +# x-ms-original-file: 2025-03-01-preview/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 effeb10c9ef5..9a8a09ed2ac4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_access.create( resource_group_name="rg1", service_name="apimService1", access_name="access", - if_match="*", parameters={"properties": {"enabled": True}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateTenantAccess.json +# x-ms-original-file: 2025-03-01-preview/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 23b89f15b34e..976fd3d9591f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.user.create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateUser.json +# x-ms-original-file: 2025-03-01-preview/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 0faebd3fa563..526df3900f5d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.begin_create_or_update( @@ -48,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWebsocketApi.json +# x-ms-original-file: 2025-03-01-preview/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 index 8000797ddca7..3efb9b371e77 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspace.json +# x-ms-original-file: 2025-03-01-preview/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 index 474cdf1f515c..8080bc73cdea 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_logger.create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceAILogger.json +# x-ms-original-file: 2025-03-01-preview/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 index 8a48652f213a..245b193cbbf5 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api.begin_create_or_update( @@ -52,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceApi.json +# x-ms-original-file: 2025-03-01-preview/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 index 692301a29810..591c5221c6a1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_diagnostic.create_or_update( @@ -55,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index 8f9f42c6383d..f887e2102435 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_operation.create_or_update( @@ -65,6 +65,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 index 1c7ee5d34cc8..27c27442a7a8 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_operation_policy.create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceApiOperationPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index ccaabd4e9f86..51de36339b96 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_policy.create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceApiPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index 97ad4900620c..c22167b5fde7 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_release.create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceApiRelease.json +# x-ms-original-file: 2025-03-01-preview/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 index 215cf27b3060..ab17893a3339 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_schema.begin_create_or_update( @@ -48,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceApiSchema.json +# x-ms-original-file: 2025-03-01-preview/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 index dd6b462ebc10..17a29a099d9c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_version_set.create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 index 0d53d43ef18f..b303432617f2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_backend.create_or_update( @@ -53,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceBackendProxyBackend.json +# x-ms-original-file: 2025-03-01-preview/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 index 6cae8dd1e2ad..c6020c666d8e 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_backend.create_or_update( @@ -56,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceBackendServiceFabric.json +# x-ms-original-file: 2025-03-01-preview/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 index 46312c118f2d..69f45bd8bd89 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_certificate.create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceCertificate.json +# x-ms-original-file: 2025-03-01-preview/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 index d01afe1e7d49..d1ce3a509612 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_certificate.create_or_update( @@ -47,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceCertificateWithKeyVault.json +# x-ms-original-file: 2025-03-01-preview/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 index 2185a50707d3..dc707702c005 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_diagnostic.create_or_update( @@ -54,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index be6d5429f5b0..3afa381fa303 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_logger.create_or_update( @@ -49,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceEHLogger.json +# x-ms-original-file: 2025-03-01-preview/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 index d7aa30de200a..368b7a420a43 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_group.create_or_update( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceGroup.json +# x-ms-original-file: 2025-03-01-preview/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 index 4116fe48f1e8..3d9d627a4319 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_group.create_or_update( @@ -47,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceGroupExternal.json +# x-ms-original-file: 2025-03-01-preview/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 index 7a4d1ea7f888..57bfd32f5c02 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_group_user.create( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceGroupUser.json +# x-ms-original-file: 2025-03-01-preview/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 index dfa36a7ffcc6..cd6952b37e17 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_named_value.begin_create_or_update( @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 index db83334848fc..7d3ab68c659f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_named_value.begin_create_or_update( @@ -50,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceNamedValueWithKeyVault.json +# x-ms-original-file: 2025-03-01-preview/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 index 2e9087d63a03..abaa1a13c548 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_notification.create_or_update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceNotification.json +# x-ms-original-file: 2025-03-01-preview/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 index 0e389212f0f5..0711278a8a87 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_notification_recipient_email.create_or_update( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceNotificationRecipientEmail.json +# x-ms-original-file: 2025-03-01-preview/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 index 1d82a67db137..43fef287e4ca 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_notification_recipient_user.create_or_update( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceNotificationRecipientUser.json +# x-ms-original-file: 2025-03-01-preview/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 index f3e487c738fb..6c79a40644e3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy.create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspacePolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index 15d9a2a203c2..0fd4c340748f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy_fragment.begin_create_or_update( @@ -46,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspacePolicyFragment.json +# x-ms-original-file: 2025-03-01-preview/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 index 3cc89fa5c1fb..e0cc8fcfeaba 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspacePolicyNonXmlEncoded.json +# x-ms-original-file: 2025-03-01-preview/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 index 8d23a80db094..10dec301d293 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway.begin_create_or_update( @@ -50,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspacePremiumGateway.json +# x-ms-original-file: 2025-03-01-preview/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 index d6efef583b0a..32aee7ca1550 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product.create_or_update( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceProduct.json +# x-ms-original-file: 2025-03-01-preview/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 index 0d004ae8d0b3..1cc7a86bc7c4 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_api_link.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceProductApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 8eb41acdb54e..62420fccda50 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_group_link.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceProductGroupLink.json +# x-ms-original-file: 2025-03-01-preview/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 index b02dbe42b4ce..09d5c0962773 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_policy.create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceProductPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index 013320f4f6fd..701b97f2eb07 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_global_schema.begin_create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceSchema.json +# x-ms-original-file: 2025-03-01-preview/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 index f331f2ffd9c6..0b2411c9d137 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_subscription.create_or_update( @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 index 16c3c0729965..3c106183bc6b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag.create_or_update( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceTag.json +# x-ms-original-file: 2025-03-01-preview/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 index 8e124cad9d78..8d6ace5f3ecf 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag_api_link.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceTagApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index a875a60101b7..21f5df7b4824 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag_operation_link.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceTagOperationLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 1e7495b3f1e9..ea1f0508f768 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag_product_link.create_or_update( @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementCreateWorkspaceTagProductLink.json +# x-ms-original-file: 2025-03-01-preview/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 3a5a44eeb66b..a4a544365f50 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api.begin_delete( resource_group_name="rg1", service_name="apimService1", api_id="echo-api", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ).result() -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApi.json +# x-ms-original-file: 2025-03-01-preview/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 0bc9f8897041..593766d5c249 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_diagnostic.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", api_id="57d1f7558aa04f15146d9d8a", diagnostic_id="applicationinsights", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 ea57eb405683..64b32b08f50a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_issue.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", api_id="57d1f7558aa04f15146d9d8a", issue_id="57d2ef278aa04f0ad01d6cdc", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiIssue.json +# x-ms-original-file: 2025-03-01-preview/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 689a28fe21f6..1bd3cd2b78c0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_issue_attachment.delete( @@ -36,10 +36,11 @@ def main(): api_id="57d1f7558aa04f15146d9d8a", issue_id="57d2ef278aa04f0ad01d6cdc", attachment_id="57d2ef278aa04f0888cba3f3", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiIssueAttachment.json +# x-ms-original-file: 2025-03-01-preview/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 3bd0a3195bcb..b7b60ac8cba6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_issue_comment.delete( @@ -36,10 +36,11 @@ def main(): api_id="57d1f7558aa04f15146d9d8a", issue_id="57d2ef278aa04f0ad01d6cdc", comment_id="599e29ab193c3c0bd0b3e2fb", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiIssueComment.json +# x-ms-original-file: 2025-03-01-preview/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 e975ff58f218..b03037758ebc 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_operation.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", api_id="57d2ef278aa04f0888cba3f3", operation_id="57d2ef278aa04f0ad01d6cdc", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 d3b201ceadc5..608b2cef562c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_operation_policy.delete( @@ -36,10 +36,11 @@ def main(): api_id="testapi", operation_id="testoperation", policy_id="policy", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiOperationPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 a86fb30fd36c..4827a81b23b3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.tag.detach_from_operation( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiOperationTag.json +# x-ms-original-file: 2025-03-01-preview/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 c265dfcbb7a7..7866421ba62b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_policy.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", api_id="loggerId", policy_id="policy", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 b297cbedae33..2d0168b1f929 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_release.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", api_id="5a5fcc09124a7fa9b89f2f1d", release_id="testrev", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiRelease.json +# x-ms-original-file: 2025-03-01-preview/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 5087b7ed414b..22bcc6272f0b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_schema.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", api_id="59d5b28d1f7fab116c282650", schema_id="59d5b28e1f7fab116402044e", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiSchema.json +# x-ms-original-file: 2025-03-01-preview/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 ae0b6d05ba1d..002fe8269652 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.tag.detach_from_api( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiTag.json +# x-ms-original-file: 2025-03-01-preview/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 97d8b5a3b4d9..d81b82aee7e9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_tag_description.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", api_id="59d5b28d1f7fab116c282650", tag_description_id="59d5b28e1f7fab116402044e", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiTagDescription.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteApiTagDescription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tool.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tool.py new file mode 100644 index 000000000000..1f9974f54f6e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_api_tool.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) Python 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_api_tool.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="SUBSCRIPTION_ID", + ) + + client.api_tool.delete( + resource_group_name="rg1", + service_name="apimService1", + api_id="57d2ef278aa04f0888cba3f3", + tool_id="57d2ef278aa04f0ad01d6cdc", + ) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteApiTool.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 b077e0fd8492..30599d96cc2c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_version_set.delete( resource_group_name="rg1", service_name="apimService1", version_set_id="a1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 7e39c4aa4942..826e44c016d2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_wiki.delete( resource_group_name="rg1", service_name="apimService1", api_id="57d1f7558aa04f15146d9d8a", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteApiWiki.json +# x-ms-original-file: 2025-03-01-preview/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 880c14619d43..e54a175fc4e0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.authorization.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", authorization_provider_id="aadwithauthcode", authorization_id="authz1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteAuthorization.json +# x-ms-original-file: 2025-03-01-preview/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 521323266f09..662ce94b3d1d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.authorization_access_policy.delete( @@ -36,10 +36,11 @@ def main(): authorization_provider_id="aadwithauthcode", authorization_id="authz1", authorization_access_policy_id="fe0bed83-631f-4149-bd0b-0464b1bc7cab", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteAuthorizationAccessPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 e711686aa504..f6e4624bc9d4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.authorization_provider.delete( resource_group_name="rg1", service_name="apimService1", authorization_provider_id="aadwithauthcode", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteAuthorizationProvider.json +# x-ms-original-file: 2025-03-01-preview/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 64548ddad616..f21cf2084473 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.authorization_server.delete( resource_group_name="rg1", service_name="apimService1", authsid="newauthServer2", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteAuthorizationServer.json +# x-ms-original-file: 2025-03-01-preview/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 691f4d0bd22c..7b8eb3732bb4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.backend.delete( resource_group_name="rg1", service_name="apimService1", backend_id="sfbackend", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteBackend.json +# x-ms-original-file: 2025-03-01-preview/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 96f025bbca51..1390f37107df 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.cache.delete( resource_group_name="rg1", service_name="apimService1", cache_id="southindia", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteCache.json +# x-ms-original-file: 2025-03-01-preview/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 6ff5b5d2d7c3..fc70a6263bad 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.certificate.delete( resource_group_name="rg1", service_name="apimService1", certificate_id="tempcert", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteCertificate.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteCertificate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_client_application.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_client_application.py new file mode 100644 index 000000000000..26ad3e9d85ce --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_client_application.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) Python 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_client_application.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="SUBSCRIPTION_ID", + ) + + client.client_application.delete( + resource_group_name="rg1", + service_name="apimService1", + client_application_id="testAppId", + ) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteClientApplication.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_client_application_product_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_client_application_product_link.py new file mode 100644 index 000000000000..0e9e119b0065 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_client_application_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) Python 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_client_application_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="SUBSCRIPTION_ID", + ) + + client.client_application_product_link.delete( + resource_group_name="rg1", + service_name="apimService1", + client_application_id="testAppId", + client_application_product_link_id="link1", + ) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteClientApplicationProductLink.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 3dcaa0ea2471..ba37764822c0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.content_type.delete( resource_group_name="rg1", service_name="apimService1", content_type_id="page", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteContentType.json +# x-ms-original-file: 2025-03-01-preview/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 4c7fba274191..13a10f7c74ef 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.content_item.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", content_type_id="page", content_item_id="4e3cf6a5-574a-ba08-1f23-2e7a38faa6d8", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteContentTypeContentItem.json +# x-ms-original-file: 2025-03-01-preview/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 0eca0bd561a3..5f48bd93a2c2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.diagnostic.delete( resource_group_name="rg1", service_name="apimService1", diagnostic_id="applicationinsights", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteDiagnostic.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_documentation.py new file mode 100644 index 000000000000..dc13b47ae517 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_documentation.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) Python 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_documentation.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="SUBSCRIPTION_ID", + ) + + client.documentation.delete( + resource_group_name="rg1", + service_name="apimService1", + documentation_id="57d1f7558aa04f15146d9d8a", + etag="str", + match_condition=~azure.core.MatchConditions, + ) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteDocumentation.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 8e79173fab80..5b42aa118c31 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.gateway.delete( resource_group_name="rg1", service_name="apimService1", gateway_id="gw1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGateway.json +# x-ms-original-file: 2025-03-01-preview/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 73ae0347b23d..2b42865a6af7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.gateway_api.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGatewayApi.json +# x-ms-original-file: 2025-03-01-preview/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 d136aea8eba5..6966320d37ad 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.gateway_certificate_authority.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", gateway_id="gw1", certificate_id="default", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGatewayCertificateAuthority.json +# x-ms-original-file: 2025-03-01-preview/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 index 576c884e175b..21e969f47ebc 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.api_gateway_config_connection.begin_delete( resource_group_name="rg1", gateway_name="standard-gw-01", config_connection_name="gcc-01", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ).result() -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGatewayConfigConnection.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteGatewayConfigConnection.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_hostname_binding.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_hostname_binding.py new file mode 100644 index 000000000000..62e99825f416 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_gateway_hostname_binding.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) Python 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_hostname_binding.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="SUBSCRIPTION_ID", + ) + + client.api_gateway_hostname_binding.begin_delete( + resource_group_name="rg1", + gateway_name="standard-gw-01", + hostname_binding_name="gcc-01", + etag="str", + match_condition=~azure.core.MatchConditions, + ).result() + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteGatewayHostnameBinding.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 2eedd898a948..75812741ba8d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.gateway_hostname_configuration.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", gateway_id="gw1", hc_id="default", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGatewayHostnameConfiguration.json +# x-ms-original-file: 2025-03-01-preview/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 5df7cb57c336..9ba0a4a0f154 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.global_schema.delete( resource_group_name="rg1", service_name="apimService1", schema_id="schema1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGlobalSchema.json +# x-ms-original-file: 2025-03-01-preview/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 508ad0d2bc36..2c4bec9af343 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.graph_ql_api_resolver.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", api_id="57d2ef278aa04f0888cba3f3", resolver_id="57d2ef278aa04f0ad01d6cdc", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGraphQLApiResolver.json +# x-ms-original-file: 2025-03-01-preview/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 a65046a4660d..85316da25e80 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.graph_ql_api_resolver_policy.delete( @@ -36,10 +36,11 @@ def main(): api_id="testapi", resolver_id="testResolver", policy_id="policy", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGraphQLApiResolverPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 66f8a2aee421..98e9c1447e09 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.group.delete( resource_group_name="rg1", service_name="apimService1", group_id="aadGroup", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGroup.json +# x-ms-original-file: 2025-03-01-preview/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 21b726533a8f..06e301621bee 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.group_user.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteGroupUser.json +# x-ms-original-file: 2025-03-01-preview/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 b669c4f8bda6..8cdcefb26bae 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.identity_provider.delete( resource_group_name="rg1", service_name="apimService1", identity_provider_name="aad", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteIdentityProvider.json +# x-ms-original-file: 2025-03-01-preview/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 13f0de73cd92..a9e45612ec79 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.logger.delete( resource_group_name="rg1", service_name="apimService1", logger_id="loggerId", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteLogger.json +# x-ms-original-file: 2025-03-01-preview/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 041c2424f34b..9d2a8d7d0fd7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.named_value.delete( resource_group_name="rg1", service_name="apimService1", named_value_id="testprop2", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 223a5594dc14..130814ba01c5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.notification_recipient_email.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteNotificationRecipientEmail.json +# x-ms-original-file: 2025-03-01-preview/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 c25c57e09207..535fece15d10 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.notification_recipient_user.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteNotificationRecipientUser.json +# x-ms-original-file: 2025-03-01-preview/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 cda9d2b3ba6a..f80d72df52b8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.open_id_connect_provider.delete( resource_group_name="rg1", service_name="apimService1", opid="templateOpenIdConnect3", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteOpenIdConnectProvider.json +# x-ms-original-file: 2025-03-01-preview/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 17aaf81c6816..b970307323c4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.policy.delete( resource_group_name="rg1", service_name="apimService1", policy_id="policy", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeletePolicy.json +# x-ms-original-file: 2025-03-01-preview/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 33010af4b274..b9384ce7f2ad 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.policy_fragment.delete( resource_group_name="rg1", service_name="apimService1", id="policyFragment1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeletePolicyFragment.json +# x-ms-original-file: 2025-03-01-preview/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 index e22f5f543f12..93cae759f2d1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.policy_restriction.delete( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeletePolicyRestriction.json +# x-ms-original-file: 2025-03-01-preview/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 f85c5a7dee58..07aeb8d3b12f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.private_endpoint_connection.begin_delete( @@ -37,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeletePrivateEndpointConnection.json +# x-ms-original-file: 2025-03-01-preview/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 b5b68d97ef72..9a70446f024e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.product.delete( resource_group_name="rg1", service_name="apimService1", product_id="testproduct", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteProduct.json +# x-ms-original-file: 2025-03-01-preview/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 9b962b9d32b8..a8f42827ec3d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.product_api.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteProductApi.json +# x-ms-original-file: 2025-03-01-preview/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 index 1c4d5e58a93a..5bf86414421e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.product_api_link.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteProductApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 206cdf94fc6b..56e0aa1e7333 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.product_group.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteProductGroup.json +# x-ms-original-file: 2025-03-01-preview/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 index 34421decc0ae..2f6710a98f81 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.product_group_link.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteProductGroupLink.json +# x-ms-original-file: 2025-03-01-preview/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 0dad49ed4618..78c40ac4b77f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.product_policy.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", product_id="testproduct", policy_id="policy", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteProductPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 aa25afc8a548..4b75b7c8b9d9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.tag.detach_from_product( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteProductTag.json +# x-ms-original-file: 2025-03-01-preview/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 8e82b065a69b..01900673741c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.product_wiki.delete( resource_group_name="rg1", service_name="apimService1", product_id="57d1f7558aa04f15146d9d8a", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteProductWiki.json +# x-ms-original-file: 2025-03-01-preview/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 a69e1b2bdd1c..d04d34e903cf 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.subscription.delete( resource_group_name="rg1", service_name="apimService1", sid="testsub", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 bc7c22c751ab..aa5d573bd69b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.tag.delete( resource_group_name="rg1", service_name="apimService1", tag_id="tagId1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteTag.json +# x-ms-original-file: 2025-03-01-preview/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 index e91a8eaac8ae..99329c3d7295 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.tag_api_link.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteTagApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 898177d88fd9..e83dceb67743 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.tag_operation_link.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteTagOperationLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 7f370962f71f..14b6ee00c727 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.tag_product_link.delete( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteTagProductLink.json +# x-ms-original-file: 2025-03-01-preview/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 2fc626ffbf2a..306cb0a952ef 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.email_template.delete( resource_group_name="rg1", service_name="apimService1", template_name="newIssueNotificationMessage", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteTemplate.json +# x-ms-original-file: 2025-03-01-preview/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 b4bf043d5deb..24d56d25567d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.user.begin_delete( resource_group_name="rg1", service_name="apimService1", user_id="5931a75ae4bbd512288c680b", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ).result() -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteUser.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementDeleteUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace.py index c5c033b98cef..eeb91c916442 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_delete_workspace.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace.delete( resource_group_name="rg1", service_name="apimService1", workspace_id="wks1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspace.json +# x-ms-original-file: 2025-03-01-preview/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 index b34094444532..3e804ab0023d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_api.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", api_id="echo-api", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceApi.json +# x-ms-original-file: 2025-03-01-preview/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 index 6af7ef6d0461..b9a03fd5aedb 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_api_diagnostic.delete( @@ -36,10 +36,11 @@ def main(): workspace_id="wks1", api_id="57d1f7558aa04f15146d9d8a", diagnostic_id="applicationinsights", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index 8e435c5f1ef1..0f25223ef19d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_api_operation.delete( @@ -36,10 +36,11 @@ def main(): workspace_id="wks1", api_id="57d2ef278aa04f0888cba3f3", operation_id="57d2ef278aa04f0ad01d6cdc", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 index dbc273ecc342..7e65fb483b5e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_api_operation_policy.delete( @@ -37,10 +37,11 @@ def main(): api_id="testapi", operation_id="testoperation", policy_id="policy", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceApiOperationPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index 8d6760ad5588..69d84d355d3a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_api_policy.delete( @@ -36,10 +36,11 @@ def main(): workspace_id="wks1", api_id="loggerId", policy_id="policy", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceApiPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index c47f641a14f8..35de36abe024 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_api_release.delete( @@ -36,10 +36,11 @@ def main(): workspace_id="wks1", api_id="5a5fcc09124a7fa9b89f2f1d", release_id="testrev", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceApiRelease.json +# x-ms-original-file: 2025-03-01-preview/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 index e596d47627ee..74e0b101c8ca 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_api_schema.delete( @@ -36,10 +36,11 @@ def main(): workspace_id="wks1", api_id="59d5b28d1f7fab116c282650", schema_id="59d5b28e1f7fab116402044e", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceApiSchema.json +# x-ms-original-file: 2025-03-01-preview/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 index 4cf451d97b74..ed67dc1fef7a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_api_version_set.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", version_set_id="a1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 index 4ed86bfdd590..3c13889fec90 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_backend.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", backend_id="sfbackend", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceBackend.json +# x-ms-original-file: 2025-03-01-preview/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 index f71fa7c33d5e..eea772457dc3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_certificate.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", certificate_id="tempcert", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceCertificate.json +# x-ms-original-file: 2025-03-01-preview/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 index 2acff84d3976..849057399a96 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_diagnostic.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", diagnostic_id="applicationinsights", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index bec6fac2b203..0f1cd4ce29f9 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_group.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", group_id="aadGroup", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceGroup.json +# x-ms-original-file: 2025-03-01-preview/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 index ff195eafe25e..6982db231e92 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_group_user.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceGroupUser.json +# x-ms-original-file: 2025-03-01-preview/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 index 48d5054d637f..e03dd945e8e7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_logger.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", logger_id="loggerId", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceLogger.json +# x-ms-original-file: 2025-03-01-preview/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 index 8f896cf2399d..12d4fce9a02b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_named_value.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", named_value_id="testprop2", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 index 199f21b0a5de..3801cca470f6 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_notification_recipient_email.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceNotificationRecipientEmail.json +# x-ms-original-file: 2025-03-01-preview/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 index ceda0f4b9bd6..f679f4978e09 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_notification_recipient_user.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceNotificationRecipientUser.json +# x-ms-original-file: 2025-03-01-preview/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 index e7449a72d326..b860934d8ead 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_policy.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", policy_id="policy", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspacePolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index 4723f50c9ec4..d4f34ff46f93 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_policy_fragment.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", id="policyFragment1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspacePolicyFragment.json +# x-ms-original-file: 2025-03-01-preview/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 index 69886b55df0f..b20dd2d01e07 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_product.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", product_id="testproduct", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceProduct.json +# x-ms-original-file: 2025-03-01-preview/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 index 6c66f87f871f..bc9e4107e72a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_product_api_link.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceProductApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 01979ce605cc..a8a72a5ec676 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_product_group_link.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceProductGroupLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 32fa610bc02f..02f1a693f645 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_product_policy.delete( @@ -36,10 +36,11 @@ def main(): workspace_id="wks1", product_id="testproduct", policy_id="policy", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceProductPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index ff1b8ea83fab..0bae7644d203 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_global_schema.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", schema_id="schema1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceSchema.json +# x-ms-original-file: 2025-03-01-preview/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 index 7b7ed91df621..6c311eda37a5 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_subscription.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", sid="testsub", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 index 2ebea9256cbe..b2319981927c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_tag.delete( @@ -35,10 +35,11 @@ def main(): service_name="apimService1", workspace_id="wks1", tag_id="tagId1", - if_match="*", + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceTag.json +# x-ms-original-file: 2025-03-01-preview/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 index 22403a2634a7..5187cad33312 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_tag_api_link.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceTagApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 3603fdee4a07..87a481c1abab 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_tag_operation_link.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceTagOperationLink.json +# x-ms-original-file: 2025-03-01-preview/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 index e03fd829e7a2..a6ff01acd133 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_tag_product_link.delete( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementDeleteWorkspaceTagProductLink.json +# x-ms-original-file: 2025-03-01-preview/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 eee69589bbc7..a3d749514759 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementDeletedServicesListBySubscription.json +# x-ms-original-file: 2025-03-01-preview/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 40c0c0f74f92..dced5e7e82f5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementDeletedServicesPurge.json +# x-ms-original-file: 2025-03-01-preview/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 index de6af7d15176..2a70ee1522a1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway.begin_delete( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGatewayDeleteGateway.json +# x-ms-original-file: 2025-03-01-preview/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 470413d31ffd..5e9fdc3c9cde 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.gateway.generate_token( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGatewayGenerateToken.json +# x-ms-original-file: 2025-03-01-preview/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 index 90924c4841bb..f4899a002b48 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGatewayGetGateway.json +# x-ms-original-file: 2025-03-01-preview/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 index cbfeaa1423e6..a528ef445414 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.gateway.invalidate_debug_credentials( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGatewayInvalidateDebugCredentials.json +# x-ms-original-file: 2025-03-01-preview/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 index b7bf5b436553..20297a899c5b 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.gateway.list_debug_credentials( @@ -43,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGatewayListDebugCredentials.json +# x-ms-original-file: 2025-03-01-preview/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 9c971118af79..43daebf2895c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.gateway.list_keys( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGatewayListKeys.json +# x-ms-original-file: 2025-03-01-preview/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 index 14b96473b917..4dbe00f724b9 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.gateway.list_trace( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGatewayListTrace.json +# x-ms-original-file: 2025-03-01-preview/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 479db1037122..a064e1535bfd 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.gateway.regenerate_key( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGatewayRegenerateKey.json +# x-ms-original-file: 2025-03-01-preview/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 692b9b7d7eee..7f1c89603bdb 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiContract.json +# x-ms-original-file: 2025-03-01-preview/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 6b79048f601b..65e87191fbd2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_diagnostic.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 bd03489276dd..e2202b5071dc 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_export.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiExportInOpenApi2dot0.json +# x-ms-original-file: 2025-03-01-preview/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 5daa4b79b251..60590f303399 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_export.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiExportInOpenApi3dot0.json +# x-ms-original-file: 2025-03-01-preview/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 5598ed0e87e5..623dde510314 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_issue.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiIssue.json +# x-ms-original-file: 2025-03-01-preview/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 510292e3042f..c4b3c5c4a1a3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetApiIssueAttachment.json +# x-ms-original-file: 2025-03-01-preview/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 03c8e719df86..029f24f40cae 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetApiIssueComment.json +# x-ms-original-file: 2025-03-01-preview/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 87388764806e..423f26f4f0c2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_operation.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 3bb415c614d5..80738c52d8cf 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_operation.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiOperationPetStore.json +# x-ms-original-file: 2025-03-01-preview/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 2b8ebbadea8c..c48e5dfd990e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_operation_policy.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiOperationPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 0b9b4bd3a49b..5a2189c5c23c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetApiOperationTag.json +# x-ms-original-file: 2025-03-01-preview/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 93e637270856..bfde53310fd9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_policy.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 cbc5fd6f7011..12116b8509cc 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_release.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiRelease.json +# x-ms-original-file: 2025-03-01-preview/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 0d79fd3615b1..2a2e6c252a98 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiRevision.json +# x-ms-original-file: 2025-03-01-preview/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 429d3d16df02..d3812f8b6082 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_schema.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiSchema.json +# x-ms-original-file: 2025-03-01-preview/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 1d410768acd8..7e02e26cb269 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetApiTag.json +# x-ms-original-file: 2025-03-01-preview/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 1274752c1d30..8048e9f32738 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetApiTagDescription.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementGetApiTagDescription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tool.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tool.py new file mode 100644 index 000000000000..29cb3222c7fe --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_api_tool.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) Python 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_api_tool.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="SUBSCRIPTION_ID", + ) + + response = client.api_tool.get( + resource_group_name="rg1", + service_name="apimService1", + api_id="github-mcp-api", + tool_id="findRepositories", + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementGetApiTool.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 991df92ab3e7..3fd71c75fb7f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 1b1ad325b541..4e47171da14b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_wiki.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetApiWiki.json +# x-ms-original-file: 2025-03-01-preview/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 b078b880eb59..7c331ff300b3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetAuthorization.json +# x-ms-original-file: 2025-03-01-preview/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 ef4d94eb1910..f9b185b1dbe6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetAuthorizationAccessPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 0c9440cc2f83..63086644cca3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_login_links.post( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetAuthorizationLoginRequest.json +# x-ms-original-file: 2025-03-01-preview/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 3c8032ede062..8416c348773f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_provider.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetAuthorizationProvider.json +# x-ms-original-file: 2025-03-01-preview/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 48e1a8489767..966c68121c1a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_server.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetAuthorizationServer.json +# x-ms-original-file: 2025-03-01-preview/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 98bbf00a0b0c..8b63cd6f21e4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.backend.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetBackend.json +# x-ms-original-file: 2025-03-01-preview/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 affb48c497dd..60d284e711b7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.cache.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetCache.json +# x-ms-original-file: 2025-03-01-preview/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 90a4ea832ed3..9c3660824dc2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.certificate.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetCertificate.json +# x-ms-original-file: 2025-03-01-preview/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 92f7e10466c5..315da1f8fcba 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.certificate.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetCertificateWithKeyVault.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementGetCertificateWithKeyVault.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_client_application.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_client_application.py new file mode 100644 index 000000000000..83dc13a3f531 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_client_application.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) Python 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_client_application.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="SUBSCRIPTION_ID", + ) + + response = client.client_application.get( + resource_group_name="rg1", + service_name="apimService1", + client_application_id="testAppId", + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementGetClientApplication.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_client_application_product_link.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_client_application_product_link.py new file mode 100644 index 000000000000..472996db15b0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_client_application_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) Python 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_client_application_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="SUBSCRIPTION_ID", + ) + + response = client.client_application_product_link.get( + resource_group_name="rg1", + service_name="apimService1", + client_application_id="testAppId", + client_application_product_link_id="link1", + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementGetClientApplicationProductLink.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 b38a024ae902..07b71c975ae5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.content_type.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetContentType.json +# x-ms-original-file: 2025-03-01-preview/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 b2b6b372386e..4ab68b8a51b0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.content_item.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetContentTypeContentItem.json +# x-ms-original-file: 2025-03-01-preview/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 45f585d7545d..964422898459 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetDeletedServiceByName.json +# x-ms-original-file: 2025-03-01-preview/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 2e19b8817174..5145731f4479 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.diagnostic.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 8c2b9819fe35..d996ab541ad8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.documentation.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetDocumentation.json +# x-ms-original-file: 2025-03-01-preview/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 5daba9fc109b..b6dd780a067b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.gateway.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetGateway.json +# x-ms-original-file: 2025-03-01-preview/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 8b390996fc29..1b2b87f3f209 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetGatewayCertificateAuthority.json +# x-ms-original-file: 2025-03-01-preview/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 index ca5d594f741a..5dc9ecefea57 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway_config_connection.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetGatewayConfigConnection.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementGetGatewayConfigConnection.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_hostname_binding.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_hostname_binding.py new file mode 100644 index 000000000000..cf800d027d5e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_get_gateway_hostname_binding.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) Python 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_hostname_binding.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="SUBSCRIPTION_ID", + ) + + response = client.api_gateway_hostname_binding.get( + resource_group_name="rg1", + gateway_name="standard-gw-1", + hostname_binding_name="hb-1", + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementGetGatewayHostnameBinding.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 99ef8a9c8af0..cb29edbf1a5c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetGatewayHostnameConfiguration.json +# x-ms-original-file: 2025-03-01-preview/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 3c55c6c927fa..4ae47bccb964 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.global_schema.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetGlobalSchema1.json +# x-ms-original-file: 2025-03-01-preview/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 0ab6dc4143ff..879fa609f80e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.global_schema.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetGlobalSchema2.json +# x-ms-original-file: 2025-03-01-preview/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 aa9d927086b5..cf4ff3c740f8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetGraphQLApiResolver.json +# x-ms-original-file: 2025-03-01-preview/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 8af42fc394c8..8c04dcd1276c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.graph_ql_api_resolver_policy.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetGraphQLApiResolverPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 2da99f6ebce0..e26e54e356f9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.group.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetGroup.json +# x-ms-original-file: 2025-03-01-preview/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 d4be337d8e83..d482369c13cc 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.identity_provider.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetIdentityProvider.json +# x-ms-original-file: 2025-03-01-preview/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 74cc14942041..877b55fb8f4b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.issue.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetIssue.json +# x-ms-original-file: 2025-03-01-preview/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 fbe56ce72fb4..957d7b24aa66 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.logger.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetLogger.json +# x-ms-original-file: 2025-03-01-preview/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 e69946de487a..91b915b438f8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.named_value.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 63fab92ad053..4e06d2ac1381 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.named_value.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetNamedValueWithKeyVault.json +# x-ms-original-file: 2025-03-01-preview/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 b4e7240eca02..455e0fa4f1ed 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.notification.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetNotification.json +# x-ms-original-file: 2025-03-01-preview/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 c685f5103997..d66237705699 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetOpenIdConnectProvider.json +# x-ms-original-file: 2025-03-01-preview/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 index c3d14e210481..2a66bb7a3cca 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.operations_results.get( @@ -36,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetOperationResult.json +# x-ms-original-file: 2025-03-01-preview/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 index 849b0e26a5ff..fa0171851c5f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.operation_status.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetOperationStatus.json +# x-ms-original-file: 2025-03-01-preview/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 ff669e06c854..f45e72ee3ca5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 2eb0d5001b4a..2581cfffb040 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetPolicyFormat.json +# x-ms-original-file: 2025-03-01-preview/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 d9325382e18f..fabaad17bc33 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_fragment.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetPolicyFragment.json +# x-ms-original-file: 2025-03-01-preview/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 840fec84e1db..db6fa1d8e0af 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_fragment.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetPolicyFragmentFormat.json +# x-ms-original-file: 2025-03-01-preview/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 index b4950b3e20c6..fe8b9739e39d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_restriction.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetPolicyRestriction.json +# x-ms-original-file: 2025-03-01-preview/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 0c345a665f4e..c171edf362ea 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.portal_revision.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetPortalRevision.json +# x-ms-original-file: 2025-03-01-preview/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 720a4b63f682..8d5212e9717b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetPrivateEndpointConnection.json +# x-ms-original-file: 2025-03-01-preview/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 ca96dd8c847b..55ac0642773e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetPrivateLinkGroupResource.json +# x-ms-original-file: 2025-03-01-preview/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 f4f5f556f1b8..4c09d4ef182e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetProduct.json +# x-ms-original-file: 2025-03-01-preview/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 index 613378fd8c32..18f3597de6a7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_api_link.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetProductApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index e97e862deb6c..e55de7b613b7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_group_link.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetProductGroupLink.json +# x-ms-original-file: 2025-03-01-preview/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 e2df36ad1a40..7f226ce305f4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_policy.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetProductPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 a65b75f821db..f241e0156a9f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetProductTag.json +# x-ms-original-file: 2025-03-01-preview/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 f36774f9e47f..3cfbf36e1750 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_wiki.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetProductWiki.json +# x-ms-original-file: 2025-03-01-preview/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 568af90c2cda..5e76ec03a3ef 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetQuotaCounterKeys.json +# x-ms-original-file: 2025-03-01-preview/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 13f5bf9a5f41..9c000639ea5b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementGetQuotaCounterKeysByQuotaPeriod.json +# x-ms-original-file: 2025-03-01-preview/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 index b93e4b6f8151..5686359e3d10 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.reports.list_by_api( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetReportsByApi.json +# x-ms-original-file: 2025-03-01-preview/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 index c4ef74d1e396..7a980542c8e4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.reports.list_by_geo( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetReportsByGeo.json +# x-ms-original-file: 2025-03-01-preview/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 index b6e7f33da2d8..db8a580c9524 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.reports.list_by_operation( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetReportsByOperation.json +# x-ms-original-file: 2025-03-01-preview/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 index 49fbc8f56a87..316f34e96620 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.reports.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetReportsByProduct.json +# x-ms-original-file: 2025-03-01-preview/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 index 9aae23174eaa..9a918e3322ff 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.reports.list_by_request( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetReportsByRequest.json +# x-ms-original-file: 2025-03-01-preview/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 index e2521a5c41a1..18b98c126d9c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.reports.list_by_subscription( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetReportsBySubscription.json +# x-ms-original-file: 2025-03-01-preview/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 index 89899cd11560..334a78ae892a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -29,7 +29,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.reports.list_by_time( @@ -42,6 +42,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetReportsByTime.json +# x-ms-original-file: 2025-03-01-preview/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 index 2fd6bf9055a2..6ddae9abf9f6 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.reports.list_by_user( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetReportsByUser.json +# x-ms-original-file: 2025-03-01-preview/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 2e6a15f58ff4..6a7c2d49d306 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.subscription.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 eacfe0c0517b..1a24b3a9ab81 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetTag.json +# x-ms-original-file: 2025-03-01-preview/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 index 622faa1602da..fd1379b8dd92 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag_api_link.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetTagApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 29c1658ba196..1c7f4d2bffd8 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag_operation_link.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetTagOperationLink.json +# x-ms-original-file: 2025-03-01-preview/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 index b2b541d54ffc..d4a158d57e8f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag_product_link.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetTagProductLink.json +# x-ms-original-file: 2025-03-01-preview/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 0f224da89b24..0a0c53c8b1fa 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.email_template.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetTemplate.json +# x-ms-original-file: 2025-03-01-preview/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 babb5a8de6f0..2fdcb12f1df1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_access.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetTenantAccess.json +# x-ms-original-file: 2025-03-01-preview/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 682f840cd9ce..bcff657af6be 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_access.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetTenantGitAccess.json +# x-ms-original-file: 2025-03-01-preview/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 0e221e414435..5660ce6c57b8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_settings.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetTenantSettings.json +# x-ms-original-file: 2025-03-01-preview/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 d590836464a7..7bb89d29acb5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.user.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetUser.json +# x-ms-original-file: 2025-03-01-preview/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 0e4dda8a72d6..b7d89a00e9a5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.user_subscription.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetUserSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 index 2850b2ed10ec..3a07057f3ae0 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspace.json +# x-ms-original-file: 2025-03-01-preview/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 index bca31c5cedbd..35347a73bed9 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiContract.json +# x-ms-original-file: 2025-03-01-preview/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 index 2437b2f7884e..4d5258fc0531 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_diagnostic.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index 88cafc0032ef..5fb1e80eebac 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_export.get( @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiExportInOpenApi2dot0.json +# x-ms-original-file: 2025-03-01-preview/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 index 4fef7a6717cf..962a19e4bd71 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_export.get( @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiExportInOpenApi3dot0.json +# x-ms-original-file: 2025-03-01-preview/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 index 95de42ce84bf..13e50805b301 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_operation.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 index 733566f1e4fa..351a2967c1ce 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_operation_policy.get( @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiOperationPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index e4e0bf4ed10f..dbf50a2a6470 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_policy.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index 2bb0b36e15ed..a4f811a3d0a4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_release.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiRelease.json +# x-ms-original-file: 2025-03-01-preview/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 index f3a11d322f05..e36beda15ec3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiRevision.json +# x-ms-original-file: 2025-03-01-preview/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 index 4253dcca83cd..ba1a9b05b885 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_schema.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiSchema.json +# x-ms-original-file: 2025-03-01-preview/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 index 7a27aa04411a..c5235d5c762d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_version_set.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 index 9f842723c48b..c0b940e553de 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_backend.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceBackend.json +# x-ms-original-file: 2025-03-01-preview/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 index fbe9dc6e8583..6124a6d9d285 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_certificate.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceCertificate.json +# x-ms-original-file: 2025-03-01-preview/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 index ae1ef4ee3fe1..f39f29894d0c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_certificate.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceCertificateWithKeyVault.json +# x-ms-original-file: 2025-03-01-preview/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 index 3f0c9d65ea2a..0de9b70311b7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_diagnostic.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index 7f22494b7f6c..a3a0e9fecd93 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_group.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceGroup.json +# x-ms-original-file: 2025-03-01-preview/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 index e51bfe1dbef9..0a37feea392d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_workspace_link.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 1180953e4b91..71eef64f4c30 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_logger.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceLogger.json +# x-ms-original-file: 2025-03-01-preview/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 index eb1623b38c01..2a526716cb6f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_named_value.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 index 79d3fd02bfa4..494c405c21e2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_named_value.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceNamedValueWithKeyVault.json +# x-ms-original-file: 2025-03-01-preview/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 index f53b015c0bb6..910b28206a92 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_notification.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceNotification.json +# x-ms-original-file: 2025-03-01-preview/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 index 5bc50123fdd3..ffa642e6b010 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspacePolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index ef523879e941..aee5164ec2da 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy_fragment.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspacePolicyFragment.json +# x-ms-original-file: 2025-03-01-preview/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 index 5c4af586cd30..fb8b111f0f94 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy_fragment.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspacePolicyFragmentFormat.json +# x-ms-original-file: 2025-03-01-preview/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 index 94f13fbc78ee..84cc599b99d3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceProduct.json +# x-ms-original-file: 2025-03-01-preview/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 index 94e642bbdf28..e1f792d05ecf 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_api_link.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceProductApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 69a6a6c0f51b..00017c4e00ff 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_group_link.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceProductGroupLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 8e643f0fb5d0..50583e23eaf5 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_policy.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceProductPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index b07daf12c5d4..59c2b738864f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_global_schema.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceSchema.json +# x-ms-original-file: 2025-03-01-preview/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 index f09fb39f238d..7f46f3c3c414 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_subscription.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 index 941ed5695f84..104b5d3dfbfc 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag.get( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceTag.json +# x-ms-original-file: 2025-03-01-preview/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 index a5a0c56e4bb0..09050556466e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag_api_link.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceTagApiLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 3698736a630f..c413d24720c7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag_operation_link.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceTagOperationLink.json +# x-ms-original-file: 2025-03-01-preview/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 index 96fc64ff5c80..aed3f1359b2f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag_product_link.get( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementGetWorkspaceTagProductLink.json +# x-ms-original-file: 2025-03-01-preview/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 eb2d2d634c2f..a0f6e91a9167 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApi.json +# x-ms-original-file: 2025-03-01-preview/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 55120f9718ce..93e92ccac64b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 4e935ad978b5..bba7c220b96a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiIssue.json +# x-ms-original-file: 2025-03-01-preview/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 e3f9161016b9..acb19389294a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiIssueAttachment.json +# x-ms-original-file: 2025-03-01-preview/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 63a050bf3fa8..de3ebaaca1e0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiIssueComment.json +# x-ms-original-file: 2025-03-01-preview/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 3eda1f3f83c6..4572796db88e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 44c153ff81c9..21464afb9122 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_operation_policy.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadApiOperationPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 ac88b6098415..894328df559f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiOperationTag.json +# x-ms-original-file: 2025-03-01-preview/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 ea66db7df49d..c48671a68d7a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_policy.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadApiPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 144963a5db13..c07d51461783 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiRelease.json +# x-ms-original-file: 2025-03-01-preview/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 1d41d4b8be23..deaaae3ce489 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiSchema.json +# x-ms-original-file: 2025-03-01-preview/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 c988a99f0543..75b02fc864d5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiTag.json +# x-ms-original-file: 2025-03-01-preview/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 2cab3d4c19bd..ddff9aeb6f7a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiTagDescription.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementHeadApiTagDescription.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tool.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tool.py new file mode 100644 index 000000000000..b6a2b9b8782d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_api_tool.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) Python 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_api_tool.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="SUBSCRIPTION_ID", + ) + + response = client.api_tool.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + api_id="57d2ef278aa04f0888cba3f3", + tool_id="57d2ef278aa04f0ad01d6cdc", + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementHeadApiTool.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 79495bfdcd42..4c45bfb442b5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 23fccb0b2d45..1e73265052e3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadApiWiki.json +# x-ms-original-file: 2025-03-01-preview/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 db776675290e..c18864e7cda1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadAuthorizationServer.json +# x-ms-original-file: 2025-03-01-preview/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 5b77fc1c400e..cc83556e0242 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadBackend.json +# x-ms-original-file: 2025-03-01-preview/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 a8a0d8e44b7d..73cf268d63e1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadCache.json +# x-ms-original-file: 2025-03-01-preview/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 8036349c7ede..0e78a3cefd50 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadCertificate.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementHeadCertificate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_client_application.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_client_application.py new file mode 100644 index 000000000000..cc191661da96 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_head_client_application.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) Python 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_client_application.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="SUBSCRIPTION_ID", + ) + + response = client.client_application.get_entity_tag( + resource_group_name="rg1", + service_name="apimService1", + client_application_id="testAppId", + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementHeadClientApplication.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 2fbc9644a6f3..0585fe4fd690 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadContentTypeContentItem.json +# x-ms-original-file: 2025-03-01-preview/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 e6583287aa6d..dcbe1833b148 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadDelegationSettings.json +# x-ms-original-file: 2025-03-01-preview/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 9cc989fd6947..e835fb32a027 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 daabec137745..dc8a13d2e509 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadDocumentation.json +# x-ms-original-file: 2025-03-01-preview/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 a84a7402d8ed..dffe08312fa8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.email_template.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadEmailTemplate.json +# x-ms-original-file: 2025-03-01-preview/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 127626f467bb..3e5adf8697cc 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadGateway.json +# x-ms-original-file: 2025-03-01-preview/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 3724996b134b..68afe078941e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadGatewayApi.json +# x-ms-original-file: 2025-03-01-preview/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 9ed13643eac2..b8e899236947 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadGatewayCertificateAuthority.json +# x-ms-original-file: 2025-03-01-preview/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 d2b4e308de43..0d33b756fff6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadGatewayHostnameConfiguration.json +# x-ms-original-file: 2025-03-01-preview/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 0d14157e9d37..e159d113d61b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadGlobalSchema.json +# x-ms-original-file: 2025-03-01-preview/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 e7256f5fe26d..4519550233b9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadGraphQLApiResolver.json +# x-ms-original-file: 2025-03-01-preview/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 f6ea20b8cfc5..1dedf71139b5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.graph_ql_api_resolver_policy.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadGraphQLApiResolverPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 15f6ac66f805..e8cc75eb3634 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadGroup.json +# x-ms-original-file: 2025-03-01-preview/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 9c17f10749fd..232eef622a27 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadGroupUser.json +# x-ms-original-file: 2025-03-01-preview/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 f4f8726e228b..ff82a206ff8f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.identity_provider.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadIdentityProvider.json +# x-ms-original-file: 2025-03-01-preview/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 80f12b4d4649..e77c308d9144 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadLogger.json +# x-ms-original-file: 2025-03-01-preview/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 903ebb8e86e0..e011e301a394 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 b022b4fdc198..0041a8903744 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.notification_recipient_email.check_entity_exists( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadNotificationRecipientEmail.json +# x-ms-original-file: 2025-03-01-preview/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 3bca7f82c327..ce13ae3c3c9e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.notification_recipient_user.check_entity_exists( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadNotificationRecipientUser.json +# x-ms-original-file: 2025-03-01-preview/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 540cff22a46d..b825c9133eaf 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadOpenIdConnectProvider.json +# x-ms-original-file: 2025-03-01-preview/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 d70c908a3502..0a781f2384bf 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 f74002749e87..b717a2767b4e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadPolicyFragment.json +# x-ms-original-file: 2025-03-01-preview/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 index ef4a16a86ea9..78dd9ff87642 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_restriction.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadPolicyRestriction.json +# x-ms-original-file: 2025-03-01-preview/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 4071c8da8d3f..991ff8ca1422 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadPortalConfig.json +# x-ms-original-file: 2025-03-01-preview/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 2cd86bb0518e..650667806803 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadPortalRevision.json +# x-ms-original-file: 2025-03-01-preview/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 82092d23fb6b..f83b99fbf859 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadProduct.json +# x-ms-original-file: 2025-03-01-preview/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 e65037116177..0fa9b66be8e7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadProductApi.json +# x-ms-original-file: 2025-03-01-preview/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 a4113b654adc..ee368b368e24 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadProductGroup.json +# x-ms-original-file: 2025-03-01-preview/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 6c2ef3627d70..94645385ec31 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_policy.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadProductPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 b18ee5fe2319..2c11bd4076c7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadProductTag.json +# x-ms-original-file: 2025-03-01-preview/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 024bb20ba810..956e73e1930d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadProductWiki.json +# x-ms-original-file: 2025-03-01-preview/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 97ac903918c1..1dcc42502edb 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadSignInSettings.json +# x-ms-original-file: 2025-03-01-preview/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 e40d437165c4..0529c8532e5b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadSignUpSettings.json +# x-ms-original-file: 2025-03-01-preview/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 e0067114d334..3f881e468f23 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 d96e1ff58579..5c969d6f2703 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadTag.json +# x-ms-original-file: 2025-03-01-preview/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 7defedaa2fbf..2b1a63e55277 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_access.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadTenantAccess.json +# x-ms-original-file: 2025-03-01-preview/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 fbb3fd1dd422..22f898f8842f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementHeadUser.json +# x-ms-original-file: 2025-03-01-preview/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 index a4bc32bc6da6..35a1efda64d5 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace.get_entity_tag( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspace.json +# x-ms-original-file: 2025-03-01-preview/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 index cbfc1dc08729..d094f499e4ca 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceApi.json +# x-ms-original-file: 2025-03-01-preview/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 index 82b641e100d8..acf3c5a48182 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_diagnostic.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index 2b6dba1fe82d..79a560801e71 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_operation.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 index 7b55c1b3b3fa..d2b578baa236 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_operation_policy.get_entity_tag( @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceApiOperationPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index fa806165a882..0c90be16b3fd 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_policy.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceApiPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index f6cfdd196c50..cad962c0cf09 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_release.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceApiRelease.json +# x-ms-original-file: 2025-03-01-preview/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 index cd54c298f989..f1e6cb01c5b5 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_schema.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceApiSchema.json +# x-ms-original-file: 2025-03-01-preview/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 index 4e7dfeeb428f..ab6e237441b8 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_version_set.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 index 1c7ad9f6211f..ef5cc769252f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_backend.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceBackend.json +# x-ms-original-file: 2025-03-01-preview/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 index efc3c738d5d0..e9ea4b422c5b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_certificate.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceCertificate.json +# x-ms-original-file: 2025-03-01-preview/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 index 531acbb2df26..4586195aaa7b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_diagnostic.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index 5a4e0dd63f93..524ac8756211 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_group.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceGroup.json +# x-ms-original-file: 2025-03-01-preview/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 index bcbd51adf27d..dee452f002ab 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_group_user.check_entity_exists( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceGroupUser.json +# x-ms-original-file: 2025-03-01-preview/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 index 54ac1b465f66..2b5ab3cf8e6b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_logger.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceLogger.json +# x-ms-original-file: 2025-03-01-preview/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 index 4006cb035fca..977ed266ddca 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_named_value.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 index e4cb4fb6edc1..f6826d189d73 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_notification_recipient_email.check_entity_exists( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceNotificationRecipientEmail.json +# x-ms-original-file: 2025-03-01-preview/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 index 2fcfefe34baa..d9bfca66ee29 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_notification_recipient_user.check_entity_exists( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceNotificationRecipientUser.json +# x-ms-original-file: 2025-03-01-preview/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 index a4ec37b93067..8bd6bcc14f48 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspacePolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index 33cc865f5833..78795ff00233 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy_fragment.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspacePolicyFragment.json +# x-ms-original-file: 2025-03-01-preview/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 index b37d07eee94b..5bbc62616d43 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceProduct.json +# x-ms-original-file: 2025-03-01-preview/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 index 780ae0079302..149ca00b5fea 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_policy.get_entity_tag( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceProductPolicy.json +# x-ms-original-file: 2025-03-01-preview/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 index cee7ea9ca4fa..3261b2aa1a94 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_global_schema.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceSchema.json +# x-ms-original-file: 2025-03-01-preview/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 index 89d2bb1c2e53..c4c25bcc3d12 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_subscription.get_entity_tag( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 index 43e81d77664b..ca1f584a1750 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag.get_entity_state( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementHeadWorkspaceTag.json +# x-ms-original-file: 2025-03-01-preview/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 74dee0a955fa..cafcf677ec4f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.identity_provider.list_secrets( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementIdentityProviderListSecrets.json +# x-ms-original-file: 2025-03-01-preview/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 1bc7f79f2a26..47a010a250b2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiDiagnostics.json +# x-ms-original-file: 2025-03-01-preview/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 cdf4bcd1399a..42f1f25b35d3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiIssueAttachments.json +# x-ms-original-file: 2025-03-01-preview/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 a2e49f7e2b85..75017ca629e0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiIssueComments.json +# x-ms-original-file: 2025-03-01-preview/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 7345eb9f0b7c..64dc96220450 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiIssues.json +# x-ms-original-file: 2025-03-01-preview/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 98cb24054c52..2f7da8b34905 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiOperationPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 15dcc60f128e..b5348889f47f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiOperationTags.json +# x-ms-original-file: 2025-03-01-preview/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 16cc13dcf60f..40769cd58995 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiOperations.json +# x-ms-original-file: 2025-03-01-preview/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 ddf0c40dd81e..58e1244fe69a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiOperationsByTags.json +# x-ms-original-file: 2025-03-01-preview/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 5b47cd10271e..c1d279867df4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 d5fa0df204e5..e039f0ea0827 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiProducts.json +# x-ms-original-file: 2025-03-01-preview/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 48859d76f3be..84b64c4bdd4a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiReleases.json +# x-ms-original-file: 2025-03-01-preview/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 c5199adcc454..2d326db8b9e6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiRevisions.json +# x-ms-original-file: 2025-03-01-preview/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 c92262f9d957..70d87974feb2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiSchemas.json +# x-ms-original-file: 2025-03-01-preview/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 13d50423f329..6f6987c47a73 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiTagDescriptions.json +# x-ms-original-file: 2025-03-01-preview/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 94a63a14acbe..9dda29302d76 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiTags.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementListApiTags.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tools.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tools.py new file mode 100644 index 000000000000..424c04fea67e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_api_tools.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) Python 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_api_tools.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="SUBSCRIPTION_ID", + ) + + response = client.api_tool.list_by_api( + resource_group_name="rg1", + service_name="apimService1", + api_id="github-mcp-api", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementListApiTools.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 d3256092b390..057e9da1c764 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApiVersionSets.json +# x-ms-original-file: 2025-03-01-preview/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 5570905479fa..2bcd98ef22a8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_wikis.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListApiWikis.json +# x-ms-original-file: 2025-03-01-preview/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 1ece65c7aaaf..a17c3508935d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApis.json +# x-ms-original-file: 2025-03-01-preview/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 9be1806a23ac..f1e43826289f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListApisByTags.json +# x-ms-original-file: 2025-03-01-preview/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 a8cca433c688..7e6f696c9638 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListAuthorizationAccessPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 72f6366df591..f589ffddd4d3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListAuthorizationProviders.json +# x-ms-original-file: 2025-03-01-preview/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 61906ea9873e..9facceeb899d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListAuthorizationServers.json +# x-ms-original-file: 2025-03-01-preview/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 941b1c769588..38ee1f3e484e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListAuthorizationsAuthCode.json +# x-ms-original-file: 2025-03-01-preview/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 60431aef8ca6..6051ba9fe85c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListAuthorizationsClientCred.json +# x-ms-original-file: 2025-03-01-preview/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 9b3f80e018bb..bb457ab0a44b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListBackends.json +# x-ms-original-file: 2025-03-01-preview/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 e38689b9f0bd..ac7e2132a755 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListCaches.json +# x-ms-original-file: 2025-03-01-preview/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 ed20bcfb3ad9..ff3dcba7d7a0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListCertificates.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementListCertificates.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_client_application_product_links.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_client_application_product_links.py new file mode 100644 index 000000000000..855dc92963da --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_client_application_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) Python 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_client_application_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="SUBSCRIPTION_ID", + ) + + response = client.client_application_product_link.list_by_client_applications( + resource_group_name="rg1", + service_name="apimService1", + client_application_id="testAppId", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementListClientApplicationProductLinks.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_client_application_secrets.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_client_application_secrets.py new file mode 100644 index 000000000000..28af46ff2c8b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_client_application_secrets.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) Python 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_client_application_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="SUBSCRIPTION_ID", + ) + + response = client.client_application.list_secrets( + resource_group_name="rg1", + service_name="apimService1", + client_application_id="testAppId", + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementListClientApplicationSecrets.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_client_applications.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_client_applications.py new file mode 100644 index 000000000000..0476d2e86a70 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_client_applications.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) Python 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_client_applications.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="SUBSCRIPTION_ID", + ) + + response = client.client_application.list_by_service( + resource_group_name="rg1", + service_name="apimService1", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementListClientApplications.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 d07774df5954..efe5b7824fa4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListContentTypeContentItems.json +# x-ms-original-file: 2025-03-01-preview/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 82970f701cad..8137fc0fb4ae 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListContentTypes.json +# x-ms-original-file: 2025-03-01-preview/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 09f9b82479cb..a51911925254 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListDiagnostics.json +# x-ms-original-file: 2025-03-01-preview/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 8cd044bd2743..0cfc72e0ad77 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListDocumentations.json +# x-ms-original-file: 2025-03-01-preview/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 0a26f474e01b..d0ea5c4ed71b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListGatewayApis.json +# x-ms-original-file: 2025-03-01-preview/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 58316e92c490..d693f2007395 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListGatewayCertificateAuthorities.json +# x-ms-original-file: 2025-03-01-preview/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 index a940dacccd47..1fec9dabc095 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway_config_connection.list_by_gateway( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListGatewayConfigConnection.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementListGatewayConfigConnection.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_hostname_bindings.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_hostname_bindings.py new file mode 100644 index 000000000000..847e380da366 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_list_gateway_hostname_bindings.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) Python 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_hostname_bindings.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="SUBSCRIPTION_ID", + ) + + response = client.api_gateway_hostname_binding.list_by_gateway( + resource_group_name="rg1", + gateway_name="standard-gw-1", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementListGatewayHostnameBindings.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 3f8d90f29544..606eef3c0953 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListGatewayHostnameConfigurations.json +# x-ms-original-file: 2025-03-01-preview/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 f9090083e3cc..170be3e9f57e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListGateways.json +# x-ms-original-file: 2025-03-01-preview/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 index b01447ab6fea..e1fac4bab779 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway.list() @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListGatewaysBySubscription.json +# x-ms-original-file: 2025-03-01-preview/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 index 6f7206f5ae05..27261c5fab2d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway.list_by_resource_group( @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListGatewaysBySubscriptionAndResourceGroup.json +# x-ms-original-file: 2025-03-01-preview/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 e4b113597e1b..dd3b62487723 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListGlobalSchemas.json +# x-ms-original-file: 2025-03-01-preview/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 5e98df9c77d7..643ffcb50b81 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListGraphQLApiResolverPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 20402a60fa0c..e925b98b6a13 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListGraphQLApiResolvers.json +# x-ms-original-file: 2025-03-01-preview/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 ff871ea27caa..b4aa1a29b868 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.group_user.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListGroupUsers.json +# x-ms-original-file: 2025-03-01-preview/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 4e98ac2248fa..cb4bf7ca51ac 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListGroups.json +# x-ms-original-file: 2025-03-01-preview/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 922d5bc40ae3..2dac4bc5dfa8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListIdentityProviders.json +# x-ms-original-file: 2025-03-01-preview/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 823062fcf433..b93f018c49f3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListIssues.json +# x-ms-original-file: 2025-03-01-preview/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 d0216cee9c03..051e3fe3e0f6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListLoggers.json +# x-ms-original-file: 2025-03-01-preview/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 7dd9f48daa72..2c98791907da 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListNamedValues.json +# x-ms-original-file: 2025-03-01-preview/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 5b9d032efdf5..de8a8ef70337 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.notification_recipient_email.list_by_notification( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListNotificationRecipientEmails.json +# x-ms-original-file: 2025-03-01-preview/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 8a888f6a9ed1..f6ba7327f1f0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.notification_recipient_user.list_by_notification( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListNotificationRecipientUsers.json +# x-ms-original-file: 2025-03-01-preview/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 55ac80544c62..03e135039cc7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListNotifications.json +# x-ms-original-file: 2025-03-01-preview/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 deff2e477f0c..8deddf0b442c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListOpenIdConnectProviders.json +# x-ms-original-file: 2025-03-01-preview/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 a0a9414dcc39..0f44aebf297a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -35,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListOperations.json +# x-ms-original-file: 2025-03-01-preview/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 a8479961c8db..b454ab3ef0b9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 f476ef03ce07..c31c14407f9f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListPolicyDescriptions.json +# x-ms-original-file: 2025-03-01-preview/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 62dbd57b02ac..36840a3bf528 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListPolicyFragmentReferences.json +# x-ms-original-file: 2025-03-01-preview/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 438b961fec24..7081bd42d014 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_fragment.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListPolicyFragments.json +# x-ms-original-file: 2025-03-01-preview/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 index 2754e7a30e15..e5915ff777a0 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_restriction.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListPolicyRestrictions.json +# x-ms-original-file: 2025-03-01-preview/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 43c39151ce59..3e25eef5b095 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.portal_config.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListPortalConfig.json +# x-ms-original-file: 2025-03-01-preview/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 1480f7fb0083..4ac70b317a06 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListPortalRevisions.json +# x-ms-original-file: 2025-03-01-preview/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 e43afc274db1..7daba02c5573 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListPortalSettings.json +# x-ms-original-file: 2025-03-01-preview/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 80574ac11196..8b1fafdaa83c 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListPrivateEndpointConnections.json +# x-ms-original-file: 2025-03-01-preview/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 303328ca9b06..e4800f99e3c8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListPrivateLinkGroupResources.json +# x-ms-original-file: 2025-03-01-preview/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 index 6027777df414..8fc5768766e1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_api_link.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListProductApiLinks.json +# x-ms-original-file: 2025-03-01-preview/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 033d38196a40..ac51410b5b71 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListProductApis.json +# x-ms-original-file: 2025-03-01-preview/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 index d795d13d09e8..49d54f350221 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_group_link.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListProductGroupLinks.json +# x-ms-original-file: 2025-03-01-preview/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 8d5041e0efed..97f809d5204a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListProductGroups.json +# x-ms-original-file: 2025-03-01-preview/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 5e77250be15d..e931fb467ca2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_policy.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListProductPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 4391ea9f7005..98e4270d4b5d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_subscriptions.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListProductSubscriptions.json +# x-ms-original-file: 2025-03-01-preview/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 788ea4e95efd..3fa423c9ce13 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListProductTags.json +# x-ms-original-file: 2025-03-01-preview/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 b41fabedb3da..4ac30275d687 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_wikis.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListProductWikis.json +# x-ms-original-file: 2025-03-01-preview/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 31e7f842cad3..5e3bc7d57cc4 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListProducts.json +# x-ms-original-file: 2025-03-01-preview/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 5893c40802e4..6f77ba45bcf7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListProductsByTags.json +# x-ms-original-file: 2025-03-01-preview/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 efcd275cd818..869503993607 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListRegions.json +# x-ms-original-file: 2025-03-01-preview/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 072414c7b4b2..3fd1e67f4089 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListSecretsPortalSettingsValidationKey.json +# x-ms-original-file: 2025-03-01-preview/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 b4660acfb5d9..0ac630702bd5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_access.list_secrets( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListSecretsTenantAccess.json +# x-ms-original-file: 2025-03-01-preview/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 35672c29caf8..56c9394c31e6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListServiceBySubscription.json +# x-ms-original-file: 2025-03-01-preview/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 9d4ccb4c5755..d76c66e892ac 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListServiceBySubscriptionAndResourceGroup.json +# x-ms-original-file: 2025-03-01-preview/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 ac75367e8943..dbdb6773c8da 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListSKUs-Consumption.json +# x-ms-original-file: 2025-03-01-preview/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 465a6616acba..ab380fe948de 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListSKUs-Dedicated.json +# x-ms-original-file: 2025-03-01-preview/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 index efba98329522..be6b297e6075 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_gateway_skus.list_available_skus( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListSKUs-Gateways.json +# x-ms-original-file: 2025-03-01-preview/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 e46499257b6e..855efc587d0d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListSku.json +# x-ms-original-file: 2025-03-01-preview/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 5833523ca09c..e20c359c6443 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.subscription.list( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListSubscriptions.json +# x-ms-original-file: 2025-03-01-preview/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 index 049f41c61486..de1cbe8056b6 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag_api_link.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListTagApiLinks.json +# x-ms-original-file: 2025-03-01-preview/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 index 634087b00da4..5df801234db0 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag_operation_link.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListTagOperationLinks.json +# x-ms-original-file: 2025-03-01-preview/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 index 083b3728e805..5aa5f99f0052 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag_product_link.list_by_product( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListTagProductLinks.json +# x-ms-original-file: 2025-03-01-preview/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 4fecad49069c..4ede160345a5 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListTagResources.json +# x-ms-original-file: 2025-03-01-preview/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 f9d330913d56..f837a69da14a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListTags.json +# x-ms-original-file: 2025-03-01-preview/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 ff2eba7a8bdf..625b59dc8913 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListTemplates.json +# x-ms-original-file: 2025-03-01-preview/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 db796472e5a4..022202533758 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListTenantAccess.json +# x-ms-original-file: 2025-03-01-preview/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 f412fc344eb0..76b18604a7af 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListTenantSettings.json +# x-ms-original-file: 2025-03-01-preview/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 68774912d04a..6e1ac8f13186 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.user_group.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListUserGroups.json +# x-ms-original-file: 2025-03-01-preview/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 b3965fb09b59..02e902953d34 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.user_identities.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListUserIdentities.json +# x-ms-original-file: 2025-03-01-preview/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 292e17a9be19..2415a4d36291 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.user_subscription.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListUserSubscriptions.json +# x-ms-original-file: 2025-03-01-preview/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 7ecf7677206f..f48a875ee400 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementListUsers.json +# x-ms-original-file: 2025-03-01-preview/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 index c5b8f5df4c06..3f7addbe0b51 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_diagnostic.list_by_workspace( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceApiDiagnostics.json +# x-ms-original-file: 2025-03-01-preview/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 index 47c341e0f052..4c2bf867185a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_operation_policy.list_by_operation( @@ -41,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceApiOperationPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 index fa580f08debe..b1e59f5e0266 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_operation.list_by_api( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceApiOperations.json +# x-ms-original-file: 2025-03-01-preview/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 index 6521358e3fb7..d1925355840d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_policy.list_by_api( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceApiPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 index ee75b1fc0430..d58b6a37e06c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_release.list_by_service( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceApiReleases.json +# x-ms-original-file: 2025-03-01-preview/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 index a50252ad0929..b0803f11aabd 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_revision.list_by_service( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceApiRevisions.json +# x-ms-original-file: 2025-03-01-preview/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 index 99bbebe42666..76aa872c6cca 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_schema.list_by_api( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceApiSchemas.json +# x-ms-original-file: 2025-03-01-preview/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 index 0e28ebddb3ad..4c2423132f5b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_version_set.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceApiVersionSets.json +# x-ms-original-file: 2025-03-01-preview/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 index f4308cd39974..102988bd439a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceApis.json +# x-ms-original-file: 2025-03-01-preview/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 index 578a53e642df..15c467166fd2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_backend.list_by_workspace( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceBackends.json +# x-ms-original-file: 2025-03-01-preview/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 index fc745fc81695..8974b8d87bea 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_certificate.list_by_workspace( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceCertificates.json +# x-ms-original-file: 2025-03-01-preview/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 index af415e7811a1..e10daea6ec7f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_diagnostic.list_by_workspace( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceDiagnostics.json +# x-ms-original-file: 2025-03-01-preview/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 index c98c01ca1215..571be91f4534 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_group_user.list( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceGroupUsers.json +# x-ms-original-file: 2025-03-01-preview/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 index f5fe77f25253..5ac98c35a7d2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_group.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceGroups.json +# x-ms-original-file: 2025-03-01-preview/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 index e618cdead36b..3bf93f5cbac4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_workspace_links.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceLinks.json +# x-ms-original-file: 2025-03-01-preview/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 index 3c5781f62892..47326a2ebb8f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_logger.list_by_workspace( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceLoggers.json +# x-ms-original-file: 2025-03-01-preview/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 index e548d051cf26..c341f7e2f968 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_named_value.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceNamedValues.json +# x-ms-original-file: 2025-03-01-preview/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 index cb2568ef93ae..3f0cee858c63 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_notification_recipient_email.list_by_notification( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceNotificationRecipientEmails.json +# x-ms-original-file: 2025-03-01-preview/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 index 904ef95eb224..8479fb349fda 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_notification_recipient_user.list_by_notification( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceNotificationRecipientUsers.json +# x-ms-original-file: 2025-03-01-preview/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 index 6ee0acbf736a..9e1c0039ceb2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_notification.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceNotifications.json +# x-ms-original-file: 2025-03-01-preview/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 index 2a28911ecf32..8ced29f71582 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy.list_by_api( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspacePolicies.json +# x-ms-original-file: 2025-03-01-preview/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 index 627e3b9ae2b3..0b1664a659a2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy_fragment.list_references( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspacePolicyFragmentReferences.json +# x-ms-original-file: 2025-03-01-preview/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 index 0dcd04a40cb5..fa929fc749b4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_policy_fragment.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspacePolicyFragments.json +# x-ms-original-file: 2025-03-01-preview/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 index 1a4c5164182b..e1bf8da43c22 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_api_link.list_by_product( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceProductApiLinks.json +# x-ms-original-file: 2025-03-01-preview/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 index 4e1378cc681a..c2ec5deb78e6 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_group_link.list_by_product( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceProductGroupLinks.json +# x-ms-original-file: 2025-03-01-preview/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 index 72c833cfa096..06006f34b155 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product_policy.list_by_product( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceProductPolicies.json +# x-ms-original-file: 2025-03-01-preview/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 index 8628a4e47d3a..52ebe95b2e48 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceProducts.json +# x-ms-original-file: 2025-03-01-preview/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 index 14e31a23a940..3b346abf38ad 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_global_schema.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceSchemas.json +# x-ms-original-file: 2025-03-01-preview/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 index 04a9a7189242..1ade81acbe59 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_subscription.list( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceSubscriptions.json +# x-ms-original-file: 2025-03-01-preview/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 index 9e401400bad8..8783505fad95 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag_api_link.list_by_product( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceTagApiLinks.json +# x-ms-original-file: 2025-03-01-preview/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 index 7b9a41e2da3b..e5e845199a86 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag_operation_link.list_by_product( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceTagOperationLinks.json +# x-ms-original-file: 2025-03-01-preview/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 index 9a87ef29b998..167b068432eb 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag_product_link.list_by_product( @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceTagProductLinks.json +# x-ms-original-file: 2025-03-01-preview/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 index e58664dd6f37..884060bc2905 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag.list_by_service( @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaceTags.json +# x-ms-original-file: 2025-03-01-preview/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 index ca27ae9a6f95..035781805997 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace.list_by_service( @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementListWorkspaces.json +# x-ms-original-file: 2025-03-01-preview/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 0a43de129634..8f599abcd0e8 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementNamedValueListValue.json +# x-ms-original-file: 2025-03-01-preview/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 bf22335f527f..0f4e1e2437b0 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementOpenidConnectProviderListSecrets.json +# x-ms-original-file: 2025-03-01-preview/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 9fdd1bca6699..c6f29fb6a3af 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.begin_perform_connectivity_check_async( @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPerformConnectivityCheck.json +# x-ms-original-file: 2025-03-01-preview/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 03034b958b2f..7a1e0e4db063 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.begin_perform_connectivity_check_async( @@ -49,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPerformConnectivityCheckHttpConnect.json +# x-ms-original-file: 2025-03-01-preview/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 48f21f3ca1de..3d62f571b513 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.portal_config.get( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPortalConfig.json +# x-ms-original-file: 2025-03-01-preview/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 fdb22a8c4305..839c92e8be95 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.delegation_settings.get( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPortalSettingsGetDelegation.json +# x-ms-original-file: 2025-03-01-preview/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 732e77fc24df..b5e5e6c7f770 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementPortalSettingsGetSignIn.json +# x-ms-original-file: 2025-03-01-preview/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 bb1d43e72548..78877405b34b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementPortalSettingsGetSignUp.json +# x-ms-original-file: 2025-03-01-preview/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 f5e902c37e7b..b874fc1af82d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.delegation_settings.create_or_update( @@ -45,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPortalSettingsPutDelegation.json +# x-ms-original-file: 2025-03-01-preview/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 2a36752a5d7c..dfc94df9a287 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.sign_in_settings.create_or_update( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPortalSettingsPutSignIn.json +# x-ms-original-file: 2025-03-01-preview/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 c0eec1b0a473..c141c65c2898 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.sign_up_settings.create_or_update( @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPortalSettingsPutSignUp.json +# x-ms-original-file: 2025-03-01-preview/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 64f82253828f..c90f51978232 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,13 +27,12 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.delegation_settings.update( resource_group_name="rg1", service_name="apimService1", - if_match="*", parameters={ "properties": { "subscriptions": {"enabled": True}, @@ -42,9 +41,11 @@ def main(): "validationKey": "", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPortalSettingsUpdateDelegation.json +# x-ms-original-file: 2025-03-01-preview/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 a8aca5145bb5..18d0c73d0e64 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,17 +27,18 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.sign_in_settings.update( resource_group_name="rg1", service_name="apimService1", - if_match="*", parameters={"properties": {"enabled": True}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPortalSettingsUpdateSignIn.json +# x-ms-original-file: 2025-03-01-preview/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 61be778e5b22..185d3f6fcb1d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,22 +27,23 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.sign_up_settings.update( resource_group_name="rg1", service_name="apimService1", - if_match="*", parameters={ "properties": { "enabled": True, "termsOfService": {"consentRequired": True, "enabled": True, "text": "Terms of service text."}, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPortalSettingsUpdateSignUp.json +# x-ms-original-file: 2025-03-01-preview/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 e668c3518bbf..e475261923fb 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.authorization.confirm_consent_code( @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementPostAuthorizationConfirmConsentCodeRequest.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementPostAuthorizationConfirmConsentCodeRequest.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_authorization_provider_secret.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_authorization_provider_secret.py new file mode 100644 index 000000000000..c68ba0bc6306 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_authorization_provider_secret.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) Python 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_authorization_provider_secret.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="SUBSCRIPTION_ID", + ) + + response = client.authorization_provider.refresh_secret( + resource_group_name="rg1", + service_name="apimService1", + authorization_provider_id="aadwithkeyvault", + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementRefreshAuthorizationProviderSecret.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 31bd02d26501..f4a6a790c664 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.certificate.refresh_secret( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementRefreshCertificate.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementRefreshCertificate.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_gateway_hostname_binding_secret.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_gateway_hostname_binding_secret.py new file mode 100644 index 000000000000..4af74dcc7ee4 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_refresh_gateway_hostname_binding_secret.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) Python 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_gateway_hostname_binding_secret.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="SUBSCRIPTION_ID", + ) + + client.api_gateway_hostname_binding.begin_refresh_secret( + resource_group_name="rg1", + gateway_name="standard-gw-01", + hostname_binding_name="gcc-01", + ).result() + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementRefreshGatewayHostnameBindingSecret.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 ab36b75520c3..731b11cbcc2b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementRefreshNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 index 6f9c945b9cfe..469570600f9d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_certificate.refresh_secret( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementRefreshWorkspaceCertificate.json +# x-ms-original-file: 2025-03-01-preview/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 index 27f3bb6eb13b..848d3f8f0a7c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_named_value.begin_refresh_secret( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementRefreshWorkspaceNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 6145b7271b7a..c6de587da98d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_restore( @@ -44,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementRestoreWithAccessKey.json +# x-ms-original-file: 2025-03-01-preview/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 a22c821f2905..1b60eebaf3bd 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.check_name_availability( @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementServiceCheckNameAvailability.json +# x-ms-original-file: 2025-03-01-preview/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 083ea88a5af3..97174bb4f53b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementServiceDeleteService.json +# x-ms-original-file: 2025-03-01-preview/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 51f159ec4a13..fe78a6a858fa 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,13 +27,13 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.get_domain_ownership_identifier() print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementServiceGetDomainOwnershipIdentifier.json +# x-ms-original-file: 2025-03-01-preview/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 e536111d0efb..147c48f590db 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementServiceGetMultiRegionInternalVnet.json +# x-ms-original-file: 2025-03-01-preview/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 d6619d7e979d..2b2ef864476e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementServiceGetNetworkStatus.json +# x-ms-original-file: 2025-03-01-preview/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 c5c8d1e3cc6b..3e4e90ae9fde 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementServiceGetNetworkStatusByLocation.json +# x-ms-original-file: 2025-03-01-preview/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 78efdfd4f276..0b1086dcd712 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementServiceGetOutboundNetworkDependenciesEndpoints.json +# x-ms-original-file: 2025-03-01-preview/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 b7839f099301..34fd84e9b740 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementServiceGetService.json +# x-ms-original-file: 2025-03-01-preview/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 edf08e244cdf..f3b5a3c493fc 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementServiceGetServiceHavingMsi.json +# x-ms-original-file: 2025-03-01-preview/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 9d60e547ecec..8107c2bf37ed 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementServiceGetSsoToken.json +# x-ms-original-file: 2025-03-01-preview/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 f72ddd915e23..e238b682d146 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementServiceMigrateToStv2.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementServiceMigrateToStv2.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_refresh_key_vault_hostnames.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_refresh_key_vault_hostnames.py new file mode 100644 index 000000000000..1af6e464988e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_service_refresh_key_vault_hostnames.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) Python 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_service_refresh_key_vault_hostnames.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="SUBSCRIPTION_ID", + ) + + response = client.api_management_service.begin_refresh_hostnames( + resource_group_name="rg1", + service_name="apimService1", + ).result() + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementServiceRefreshKeyVaultHostnames.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 7f9cba814e95..30e503b73805 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.subscription.list_secrets( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementSubscriptionListSecrets.json +# x-ms-original-file: 2025-03-01-preview/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 12fb2614d057..e983192f4b53 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.subscription.regenerate_primary_key( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementSubscriptionRegeneratePrimaryKey.json +# x-ms-original-file: 2025-03-01-preview/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 6de103197540..efd498d60a9e 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.subscription.regenerate_secondary_key( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementSubscriptionRegenerateSecondaryKey.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementSubscriptionRegenerateSecondaryKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_git_regenerate_primary_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_git_regenerate_primary_key.py new file mode 100644 index 000000000000..98b81aed1bbc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_git_regenerate_primary_key.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) Python 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_tenant_access_git_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="SUBSCRIPTION_ID", + ) + + client.tenant_access_git.regenerate_primary_key( + resource_group_name="rg1", + service_name="apimService1", + access_name="access", + ) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementTenantAccessGitRegeneratePrimaryKey.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 432eea8fac60..423ab5745556 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.tenant_access_git.regenerate_secondary_key( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementTenantAccessRegenerateKey.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementTenantAccessRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_primary_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_primary_key.py new file mode 100644 index 000000000000..74f3df43b241 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_primary_key.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) Python 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_tenant_access_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="SUBSCRIPTION_ID", + ) + + client.tenant_access.regenerate_primary_key( + resource_group_name="rg1", + service_name="apimService1", + access_name="access", + ) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementTenantAccessRegeneratePrimaryKey.json +if __name__ == "__main__": + main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_secondary_key.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_secondary_key.py new file mode 100644 index 000000000000..6aadefc84de8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_tenant_access_regenerate_secondary_key.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) Python 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_tenant_access_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="SUBSCRIPTION_ID", + ) + + client.tenant_access.regenerate_secondary_key( + resource_group_name="rg1", + service_name="apimService1", + access_name="access", + ) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementTenantAccessRegenerateSecondaryKey.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 1bdc2c279791..328a266c2462 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_configuration.get_sync_state( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementTenantAccessSyncState.json +# x-ms-original-file: 2025-03-01-preview/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 6d065df3b7ff..8f700f95083a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_configuration.begin_deploy( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementTenantConfigurationDeploy.json +# x-ms-original-file: 2025-03-01-preview/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 ba9587bf21d9..9704eb3b957d 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_configuration.begin_save( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementTenantConfigurationSave.json +# x-ms-original-file: 2025-03-01-preview/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 af2ba6d5b365..050bd1189d97 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_configuration.begin_validate( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementTenantConfigurationValidate.json +# x-ms-original-file: 2025-03-01-preview/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 06d7b6ed1382..6f9f01fcfaf2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_create_or_update( @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUndelete.json +# x-ms-original-file: 2025-03-01-preview/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 e793d8fb7857..b30b3cfe6cc1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,14 +27,13 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api.update( resource_group_name="rg1", service_name="apimService1", api_id="echo-api", - if_match="*", parameters={ "properties": { "displayName": "Echo API New", @@ -42,10 +41,12 @@ def main(): "serviceUrl": "http://echoapi.cloudapp.net/api2", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateApi.json +# x-ms-original-file: 2025-03-01-preview/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 b74c593773b2..37229c6113ce 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_diagnostic.update( @@ -35,7 +35,6 @@ def main(): service_name="apimService1", api_id="echo-api", diagnostic_id="applicationinsights", - if_match="*", parameters={ "properties": { "alwaysLog": "allErrors", @@ -51,10 +50,12 @@ def main(): "sampling": {"percentage": 50, "samplingType": "fixed"}, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 dff69c4aea03..afdf2b5b6fde 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_issue.update( @@ -35,12 +35,13 @@ def main(): service_name="apimService1", api_id="57d1f7558aa04f15146d9d8a", issue_id="57d2ef278aa04f0ad01d6cdc", - if_match="*", parameters={"properties": {"state": "closed"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateApiIssue.json +# x-ms-original-file: 2025-03-01-preview/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 1ba1fcbf1f21..64646dbe3e43 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_operation.update( @@ -35,7 +35,6 @@ def main(): service_name="apimService1", api_id="echo-api", operation_id="operationId", - if_match="*", parameters={ "properties": { "displayName": "Retrieve resource", @@ -60,10 +59,12 @@ def main(): "urlTemplate": "/resource", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 73bc9b7fe125..1c8101b62abe 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_release.update( @@ -35,17 +36,18 @@ def main(): service_name="apimService1", api_id="a1", release_id="testrev", - if_match="*", parameters={ "properties": { "apiId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1", "notes": "yahooagain", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateApiRelease.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementUpdateApiRelease.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_tool.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_tool.py new file mode 100644 index 000000000000..9c1542870574 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_api_tool.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) Python 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_api_tool.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="SUBSCRIPTION_ID", + ) + + response = client.api_tool.update( + resource_group_name="rg1", + service_name="apimService1", + api_id="github-mcp-api", + tool_id="createIssue", + parameters={"properties": {"description": "This is updated description", "displayName": "createIssue"}}, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementUpdateApiTool.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 bd07a5fc195b..72be3518a947 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,14 +27,13 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_version_set.update( resource_group_name="rg1", service_name="apimService1", version_set_id="vs1", - if_match="*", parameters={ "properties": { "description": "Version configuration", @@ -42,10 +41,12 @@ def main(): "versioningScheme": "Segment", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 51e63f0a82b1..1df6e55379b3 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_wiki.update( resource_group_name="rg1", service_name="apimService1", api_id="57d1f7558aa04f15146d9d8a", - if_match="*", parameters={"properties": {"documents": [{"documentationId": "docId1"}]}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateApiWiki.json +# x-ms-original-file: 2025-03-01-preview/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 0893711b9acd..e6a39cf78c63 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,14 +27,13 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.authorization_server.update( resource_group_name="rg1", service_name="apimService1", authsid="newauthServer", - if_match="*", parameters={ "properties": { "clientId": "update", @@ -43,10 +42,12 @@ def main(): "useInTestConsole": False, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateAuthorizationServer.json +# x-ms-original-file: 2025-03-01-preview/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 62337dc6ff9f..d3cc293159ca 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,24 +27,25 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.backend.update( resource_group_name="rg1", service_name="apimService1", backend_id="proxybackend", - if_match="*", parameters={ "properties": { "description": "description5308", "tls": {"validateCertificateChain": False, "validateCertificateName": True}, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateBackend.json +# x-ms-original-file: 2025-03-01-preview/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 e65071336eaf..da800fdcfd8f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.cache.update( resource_group_name="rg1", service_name="apimService1", cache_id="c1", - if_match="*", parameters={"properties": {"useFromLocation": "westindia"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateCache.json +# x-ms-original-file: 2025-03-01-preview/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 d1116154dc2c..6df2c7346891 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,14 +27,13 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.diagnostic.update( resource_group_name="rg1", service_name="apimService1", diagnostic_id="applicationinsights", - if_match="*", parameters={ "properties": { "alwaysLog": "allErrors", @@ -50,10 +49,12 @@ def main(): "sampling": {"percentage": 50, "samplingType": "fixed"}, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementUpdateDiagnostic.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_documentation.py new file mode 100644 index 000000000000..e218b5e90fc8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_documentation.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) Python 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_documentation.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="SUBSCRIPTION_ID", + ) + + response = client.documentation.update( + resource_group_name="rg1", + service_name="apimService1", + documentation_id="57d1f7558aa04f15146d9d8a", + parameters={"properties": {"content": "content updated", "title": "Title updated"}}, + etag="str", + match_condition=~azure.core.MatchConditions, + ) + print(response) + + +# x-ms-original-file: 2025-03-01-preview/ApiManagementUpdateDocumentation.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 7e705802f2c6..0eeafa396764 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.gateway.update( resource_group_name="rg1", service_name="apimService1", gateway_id="gw1", - if_match="*", parameters={"properties": {"description": "my gateway 1", "locationData": {"name": "my location"}}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateGateway.json +# x-ms-original-file: 2025-03-01-preview/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 b03491b63901..e2757f3b6c0f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.graph_ql_api_resolver.update( @@ -35,7 +35,6 @@ def main(): service_name="apimService1", api_id="echo-api", resolver_id="resolverId", - if_match="*", parameters={ "properties": { "description": "A GraphQL Resolver example", @@ -43,10 +42,12 @@ def main(): "path": "Query/adminUsers", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateGraphQLApiResolver.json +# x-ms-original-file: 2025-03-01-preview/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 9bf0b126680b..1c65ed4dfa95 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.group.update( resource_group_name="rg1", service_name="apimService1", group_id="tempgroup", - if_match="*", parameters={"properties": {"displayName": "temp group"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateGroup.json +# x-ms-original-file: 2025-03-01-preview/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 d4f165e61d41..89bbbd16c6db 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.identity_provider.update( resource_group_name="rg1", service_name="apimService1", identity_provider_name="facebook", - if_match="*", parameters={"properties": {"clientId": "updatedfacebookid", "clientSecret": "updatedfacebooksecret"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateIdentityProvider.json +# x-ms-original-file: 2025-03-01-preview/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 9b7c14b1655e..007a1a4744f2 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.logger.update( resource_group_name="rg1", service_name="apimService1", logger_id="eh1", - if_match="*", parameters={"properties": {"description": "updating description", "loggerType": "azureEventHub"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateLogger.json +# x-ms-original-file: 2025-03-01-preview/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 ef2dc4f644fa..45183ea9dd20 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,21 +27,22 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.named_value.begin_update( resource_group_name="rg1", service_name="apimService1", named_value_id="testprop2", - if_match="*", parameters={ "properties": {"displayName": "prop3name", "secret": False, "tags": ["foo", "bar2"], "value": "propValue"} }, + etag="str", + match_condition=~azure.core.MatchConditions, ).result() print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 e69f303cdb4e..9df77fee27ea 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,21 +27,22 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.open_id_connect_provider.update( resource_group_name="rg1", service_name="apimService1", opid="templateOpenIdConnect2", - if_match="*", parameters={ "properties": {"clientSecret": "updatedsecret", "useInApiDocumentation": True, "useInTestConsole": False} }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateOpenIdConnectProvider.json +# x-ms-original-file: 2025-03-01-preview/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 index 9957d99e2551..d85e01117227 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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."}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdatePolicyRestriction.json +# x-ms-original-file: 2025-03-01-preview/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 61d0745964d6..c3455c7de147 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,14 +27,13 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.portal_config.update( resource_group_name="rg1", service_name="apimService1", portal_config_id="default", - if_match="*", parameters={ "properties": { "cors": {"allowedOrigins": ["https://contoso.com"]}, @@ -56,10 +55,12 @@ def main(): }, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdatePortalConfig.json +# x-ms-original-file: 2025-03-01-preview/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 3280a77445b8..80846ba6297a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.portal_revision.begin_update( resource_group_name="rg1", service_name="apimService1", portal_revision_id="20201112101010", - if_match="*", parameters={"properties": {"description": "portal revision update", "isCurrent": True}}, + etag="str", + match_condition=~azure.core.MatchConditions, ).result() print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdatePortalRevision.json +# x-ms-original-file: 2025-03-01-preview/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 a0705344cc38..43a3b06504f7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product.update( resource_group_name="rg1", service_name="apimService1", product_id="testproduct", - if_match="*", parameters={"properties": {"displayName": "Test Template ProductName 4"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateProduct.json +# x-ms-original-file: 2025-03-01-preview/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 8990576f6c99..e1b4acf62ea1 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.product_wiki.update( resource_group_name="rg1", service_name="apimService1", product_id="57d1f7558aa04f15146d9d8a", - if_match="*", parameters={"properties": {"documents": [{"documentationId": "docId1"}]}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateProductWiki.json +# x-ms-original-file: 2025-03-01-preview/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 d03e7ea35cf2..abafedc813c7 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.quota_by_counter_keys.update( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateQuotaCounterKey.json +# x-ms-original-file: 2025-03-01-preview/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 9b7c56fe4eeb..9db327e31472 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.quota_by_period_keys.update( @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateQuotaCounterKeyByQuotaPeriod.json +# x-ms-original-file: 2025-03-01-preview/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 7ebfbbe12918..978f2c6c24d9 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_update( @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateServiceDisableTls10.json +# x-ms-original-file: 2025-03-01-preview/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 683ce5b32a75..70d5bfebd2e6 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_update( @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateServicePublisherDetails.json +# x-ms-original-file: 2025-03-01-preview/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 eca6717e6b30..e6bd187e2ffd 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_management_service.begin_update( @@ -59,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateServiceToNewVnetAndAZs.json +# x-ms-original-file: 2025-03-01-preview/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 index 6b0fd87ee6f7..4a821791d042 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.api_gateway.begin_update( @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateStandardGateway.json +# x-ms-original-file: 2025-03-01-preview/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 7e9aba9e5525..fee5aeecd151 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.subscription.update( resource_group_name="rg1", service_name="apimService1", sid="testsub", - if_match="*", parameters={"properties": {"displayName": "testsub"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 b414d8edb7d5..5afe49ddfc5a 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tag.update( resource_group_name="rg1", service_name="apimService1", tag_id="temptag", - if_match="*", parameters={"properties": {"displayName": "temp tag"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateTag.json +# x-ms-original-file: 2025-03-01-preview/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 91cec71e7ca0..7522b2def92b 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,24 +28,25 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.email_template.update( resource_group_name="rg1", service_name="apimService1", template_name="newIssueNotificationMessage", - if_match="*", parameters={ "properties": { "body": '\r\n\r\n \r\n \r\n

Dear $DevFirstName $DevLastName,

\r\n

\r\n We are happy to let you know that your request to publish the $AppName application in the gallery has been approved. Your application has been published and can be viewed here.\r\n

\r\n

Best,

\r\n

The $OrganizationName API Team

\r\n \r\n', "subject": "Your request $IssueName was received", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateTemplate.json +# x-ms-original-file: 2025-03-01-preview/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 9ec3669c5f7c..5086b9f8bd75 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.tenant_access.update( resource_group_name="rg1", service_name="apimService1", access_name="access", - if_match="*", parameters={"properties": {"enabled": True}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateTenantAccess.json +# x-ms-original-file: 2025-03-01-preview/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 672b49904923..e2512961071b 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.user.update( resource_group_name="rg1", service_name="apimService1", user_id="5931a75ae4bbd512a88c680b", - if_match="*", parameters={"properties": {"email": "foobar@outlook.com", "firstName": "foo", "lastName": "bar"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateUser.json +# x-ms-original-file: 2025-03-01-preview/ApiManagementUpdateUser.json if __name__ == "__main__": main() diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace.py index dc8aa7ffaf55..fe2454638635 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_samples/api_management_update_workspace.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,19 +27,20 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace.update( resource_group_name="rg1", service_name="apimService1", workspace_id="wks1", - if_match="*", parameters={"properties": {"description": "workspace 1", "displayName": "my workspace"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspace.json +# x-ms-original-file: 2025-03-01-preview/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 index efd2146cc478..cd130da75f81 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api.update( @@ -35,7 +35,6 @@ def main(): service_name="apimService1", workspace_id="wks1", api_id="echo-api", - if_match="*", parameters={ "properties": { "displayName": "Echo API New", @@ -43,10 +42,12 @@ def main(): "serviceUrl": "http://echoapi.cloudapp.net/api2", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceApi.json +# x-ms-original-file: 2025-03-01-preview/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 index 655cdea20f70..b7989c4fc6f2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_diagnostic.update( @@ -36,7 +36,6 @@ def main(): workspace_id="wks1", api_id="echo-api", diagnostic_id="applicationinsights", - if_match="*", parameters={ "properties": { "alwaysLog": "allErrors", @@ -52,10 +51,12 @@ def main(): "sampling": {"percentage": 50, "samplingType": "fixed"}, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceApiDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index 6ee61e8eeabb..73a91496eb93 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_operation.update( @@ -36,7 +36,6 @@ def main(): workspace_id="wks1", api_id="echo-api", operation_id="operationId", - if_match="*", parameters={ "properties": { "displayName": "Retrieve resource", @@ -61,10 +60,12 @@ def main(): "urlTemplate": "/resource", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceApiOperation.json +# x-ms-original-file: 2025-03-01-preview/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 index 6a55a471c272..6343ebfa6204 100644 --- 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 @@ -1,8 +1,9 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +28,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_release.update( @@ -36,17 +37,18 @@ def main(): 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", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceApiRelease.json +# x-ms-original-file: 2025-03-01-preview/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 index 704d2ae112ac..f43b872fb982 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_api_version_set.update( @@ -35,7 +35,6 @@ def main(): service_name="apimService1", workspace_id="wks1", version_set_id="vs1", - if_match="*", parameters={ "properties": { "description": "Version configuration", @@ -43,10 +42,12 @@ def main(): "versioningScheme": "Segment", } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceApiVersionSet.json +# x-ms-original-file: 2025-03-01-preview/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 index c04c502cd605..4c39c597359e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_backend.update( @@ -35,17 +35,18 @@ def main(): service_name="apimService1", workspace_id="wks1", backend_id="proxybackend", - if_match="*", parameters={ "properties": { "description": "description5308", "tls": {"validateCertificateChain": False, "validateCertificateName": True}, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceBackend.json +# x-ms-original-file: 2025-03-01-preview/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 index b066819f9469..e618704dd962 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_diagnostic.update( @@ -35,7 +35,6 @@ def main(): service_name="apimService1", workspace_id="wks1", diagnostic_id="applicationinsights", - if_match="*", parameters={ "properties": { "alwaysLog": "allErrors", @@ -51,10 +50,12 @@ def main(): "sampling": {"percentage": 50, "samplingType": "fixed"}, } }, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceDiagnostic.json +# x-ms-original-file: 2025-03-01-preview/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 index b2548a244283..ef548d68aa60 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_group.update( @@ -35,12 +35,13 @@ def main(): service_name="apimService1", workspace_id="wks1", group_id="tempgroup", - if_match="*", parameters={"properties": {"displayName": "temp group"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceGroup.json +# x-ms-original-file: 2025-03-01-preview/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 index 471bb0eb4414..5371508573c2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_logger.update( @@ -35,12 +35,13 @@ def main(): service_name="apimService1", workspace_id="wks1", logger_id="eh1", - if_match="*", parameters={"properties": {"description": "updating description", "loggerType": "azureEventHub"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceLogger.json +# x-ms-original-file: 2025-03-01-preview/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 index 85c9d4fd7e72..f3028798af83 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_named_value.begin_update( @@ -35,14 +35,15 @@ def main(): service_name="apimService1", workspace_id="wks1", named_value_id="testprop2", - if_match="*", parameters={ "properties": {"displayName": "prop3name", "secret": False, "tags": ["foo", "bar2"], "value": "propValue"} }, + etag="str", + match_condition=~azure.core.MatchConditions, ).result() print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceNamedValue.json +# x-ms-original-file: 2025-03-01-preview/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 index 91968f891e98..bf8e1f4bac2c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_product.update( @@ -35,12 +35,13 @@ def main(): service_name="apimService1", workspace_id="wks1", product_id="testproduct", - if_match="*", parameters={"properties": {"displayName": "Test Template ProductName 4"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceProduct.json +# x-ms-original-file: 2025-03-01-preview/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 index d87fd27c06c7..c2243d686b51 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_subscription.update( @@ -35,12 +35,13 @@ def main(): service_name="apimService1", workspace_id="wks1", sid="testsub", - if_match="*", parameters={"properties": {"displayName": "testsub"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceSubscription.json +# x-ms-original-file: 2025-03-01-preview/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 index 4282fc70a655..9ecbdbb2601f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_tag.update( @@ -35,12 +35,13 @@ def main(): service_name="apimService1", workspace_id="wks1", tag_id="temptag", - if_match="*", parameters={"properties": {"displayName": "temp tag"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUpdateWorkspaceTag.json +# x-ms-original-file: 2025-03-01-preview/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 6ceb41846e0d..6727c903ed0f 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.user_confirmation_password.send( @@ -37,6 +37,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUserConfirmationPasswordSend.json +# x-ms-original-file: 2025-03-01-preview/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 bcc471c154b0..149e3c944bcc 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) 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/2024-05-01/examples/ApiManagementUserGenerateSsoUrl.json +# x-ms-original-file: 2025-03-01-preview/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 59b2e6711965..a34ee1cf6136 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.user.get_shared_access_token( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementUserToken.json +# x-ms-original-file: 2025-03-01-preview/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 index b8b340093d8d..ae415bad0d0e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_restriction_validations.begin_by_service( @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementValidatePolicies.json +# x-ms-original-file: 2025-03-01-preview/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 index 5971cd2f900f..44e6b454dc3e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_named_value.list_value( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementWorkspaceNamedValueListValue.json +# x-ms-original-file: 2025-03-01-preview/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 index cc3be71c89d8..f055d56a7d81 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) response = client.workspace_subscription.list_secrets( @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementWorkspaceSubscriptionListSecrets.json +# x-ms-original-file: 2025-03-01-preview/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 index 75e9c81ab0da..5e1ae8121850 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_subscription.regenerate_primary_key( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementWorkspaceSubscriptionRegeneratePrimaryKey.json +# x-ms-original-file: 2025-03-01-preview/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 index d1cf021c7808..4f316d25555f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -27,7 +27,7 @@ def main(): client = ApiManagementClient( credential=DefaultAzureCredential(), - subscription_id="00000000-0000-0000-0000-000000000000", + subscription_id="SUBSCRIPTION_ID", ) client.workspace_subscription.regenerate_secondary_key( @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/apimanagement/resource-manager/Microsoft.ApiManagement/stable/2024-05-01/examples/ApiManagementWorkspaceSubscriptionRegenerateSecondaryKey.json +# x-ms-original-file: 2025-03-01-preview/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 index f88b03f80459..ff126cac4bdd 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/conftest.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/conftest.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import os 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 index 9d82ec2a1913..67ba6b767873 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -37,7 +37,6 @@ def test_begin_perform_connectivity_check_async(self, resource_group): } }, }, - api_version="2024-05-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 index 9d1695daba05..0e9d4e59d8f4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_all_policies_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-05-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 index ad88e4d712cf..6a13e5b97006 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_all_policies_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-05-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 index ff57acef6f2c..da18199c8044 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_diagnostic_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_api_diagnostic_get_entity_tag(self, resource_group): - response = self.client.api_diagnostic.get_entity_tag( + def test_api_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_api_diagnostic_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_diagnostic_get(self, resource_group): - response = self.client.api_diagnostic.get( + def test_api_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -68,55 +53,69 @@ def test_api_diagnostic_create_or_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -130,57 +129,72 @@ def test_api_diagnostic_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -194,9 +208,21 @@ def test_api_diagnostic_delete(self, resource_group): service_name="str", api_id="str", diagnostic_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_diagnostic_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", + ) + 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_diagnostic_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_diagnostic_operations_async.py index 2afb0bd780eb..0df8002ec0ec 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_diagnostic_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-05-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_api_diagnostic_get_entity_tag(self, resource_group): - response = await self.client.api_diagnostic.get_entity_tag( + async def test_api_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_api_diagnostic_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_diagnostic_get(self, resource_group): - response = await self.client.api_diagnostic.get( + async def test_api_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -69,55 +54,69 @@ async def test_api_diagnostic_create_or_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -131,57 +130,72 @@ async def test_api_diagnostic_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -195,9 +209,21 @@ async def test_api_diagnostic_delete(self, resource_group): service_name="str", api_id="str", diagnostic_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_diagnostic_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", + ) + 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_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_export_operations.py index 65922fc0a140..40eedc28bc93 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ def test_api_export_get(self, resource_group): api_id="str", format="str", export="str", - api_version="2024-05-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 index d51805f4f5ad..f15f87cec341 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,7 +28,6 @@ async def test_api_export_get(self, resource_group): api_id="str", format="str", export="str", - api_version="2024-05-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 index 4189d0e498b3..29bc7a0e9263 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestApiManagementApiGatewayConfigConnectionOperations(AzureMgmtRecordedTes def setup_method(self, method): self.client = self.create_mgmt_client(ApiManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_api_gateway_config_connection_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_api_gateway_config_connection_get(self, resource_group): @@ -37,7 +25,6 @@ def test_api_gateway_config_connection_get(self, resource_group): resource_group_name=resource_group.name, gateway_name="str", config_connection_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -51,16 +38,25 @@ def test_api_gateway_config_connection_begin_create_or_update(self, resource_gro gateway_name="str", config_connection_name="str", parameters={ - "defaultHostname": "str", + "properties": { + "defaultHostname": "str", + "hostnames": ["str"], + "provisioningState": "str", + "sourceId": "str", + }, "etag": "str", - "hostnames": ["str"], "id": "str", "name": "str", - "provisioningState": "str", - "sourceId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -73,9 +69,20 @@ def test_api_gateway_config_connection_begin_delete(self, resource_group): resource_group_name=resource_group.name, gateway_name="str", config_connection_name="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ).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_api_gateway_config_connection_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", + ) + 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_config_connection_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_config_connection_operations_async.py index b97de5e20ee9..ed93d856b28f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestApiManagementApiGatewayConfigConnectionOperationsAsync(AzureMgmtRecord 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_api_gateway_config_connection_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-05-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_api_gateway_config_connection_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_api_gateway_config_connection_get(self, resource_group): resource_group_name=resource_group.name, gateway_name="str", config_connection_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -53,16 +40,25 @@ async def test_api_gateway_config_connection_begin_create_or_update(self, resour gateway_name="str", config_connection_name="str", parameters={ - "defaultHostname": "str", + "properties": { + "defaultHostname": "str", + "hostnames": ["str"], + "provisioningState": "str", + "sourceId": "str", + }, "etag": "str", - "hostnames": ["str"], "id": "str", "name": "str", - "provisioningState": "str", - "sourceId": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -77,10 +73,21 @@ async def test_api_gateway_config_connection_begin_delete(self, resource_group): resource_group_name=resource_group.name, gateway_name="str", config_connection_name="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) ).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_api_gateway_config_connection_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", + ) + 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_gateway_hostname_binding_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_hostname_binding_operations.py new file mode 100644 index 000000000000..c1cb8ff0027e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_hostname_binding_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) Python 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 TestApiManagementApiGatewayHostnameBindingOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_gateway_hostname_binding_get(self, resource_group): + response = self.client.api_gateway_hostname_binding.get( + resource_group_name=resource_group.name, + gateway_name="str", + hostname_binding_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_gateway_hostname_binding_begin_create_or_update(self, resource_group): + response = self.client.api_gateway_hostname_binding.begin_create_or_update( + resource_group_name=resource_group.name, + gateway_name="str", + hostname_binding_name="str", + parameters={ + "properties": { + "hostname": "str", + "keyVault": { + "secretId": "str", + "identityClientId": "str", + "lastStatus": { + "code": "str", + "lastSuccessTimeStampUtc": "2020-02-20 00:00:00", + "timeStampUtc": "2020-02-20 00:00:00", + }, + }, + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "provisioningState": "str", + }, + "etag": "str", + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ).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_api_gateway_hostname_binding_begin_delete(self, resource_group): + response = self.client.api_gateway_hostname_binding.begin_delete( + resource_group_name=resource_group.name, + gateway_name="str", + hostname_binding_name="str", + etag="str", + match_condition=~azure.core.MatchConditions, + ).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_api_gateway_hostname_binding_list_by_gateway(self, resource_group): + response = self.client.api_gateway_hostname_binding.list_by_gateway( + resource_group_name=resource_group.name, + gateway_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_gateway_hostname_binding_begin_refresh_secret(self, resource_group): + response = self.client.api_gateway_hostname_binding.begin_refresh_secret( + resource_group_name=resource_group.name, + gateway_name="str", + hostname_binding_name="str", + ).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_hostname_binding_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_hostname_binding_operations_async.py new file mode 100644 index 000000000000..41e62dd750b6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_gateway_hostname_binding_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) Python 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 TestApiManagementApiGatewayHostnameBindingOperationsAsync(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_api_gateway_hostname_binding_get(self, resource_group): + response = await self.client.api_gateway_hostname_binding.get( + resource_group_name=resource_group.name, + gateway_name="str", + hostname_binding_name="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_gateway_hostname_binding_begin_create_or_update(self, resource_group): + response = await ( + await self.client.api_gateway_hostname_binding.begin_create_or_update( + resource_group_name=resource_group.name, + gateway_name="str", + hostname_binding_name="str", + parameters={ + "properties": { + "hostname": "str", + "keyVault": { + "secretId": "str", + "identityClientId": "str", + "lastStatus": { + "code": "str", + "lastSuccessTimeStampUtc": "2020-02-20 00:00:00", + "timeStampUtc": "2020-02-20 00:00:00", + }, + }, + "certificate": {"expiry": "2020-02-20 00:00:00", "subject": "str", "thumbprint": "str"}, + "provisioningState": "str", + }, + "etag": "str", + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + ).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_api_gateway_hostname_binding_begin_delete(self, resource_group): + response = await ( + await self.client.api_gateway_hostname_binding.begin_delete( + resource_group_name=resource_group.name, + gateway_name="str", + hostname_binding_name="str", + etag="str", + match_condition=~azure.core.MatchConditions, + ) + ).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_api_gateway_hostname_binding_list_by_gateway(self, resource_group): + response = self.client.api_gateway_hostname_binding.list_by_gateway( + resource_group_name=resource_group.name, + gateway_name="str", + ) + 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_api_gateway_hostname_binding_begin_refresh_secret(self, resource_group): + response = await ( + await self.client.api_gateway_hostname_binding.begin_refresh_secret( + resource_group_name=resource_group.name, + gateway_name="str", + hostname_binding_name="str", + ) + ).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 index 4ceab583068f..1b22ac24b848 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,6 +18,17 @@ class TestApiManagementApiGatewayOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ApiManagementClient) + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_gateway_get(self, resource_group): + response = self.client.api_gateway.get( + resource_group_name=resource_group.name, + gateway_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_api_gateway_begin_create_or_update(self, resource_group): @@ -26,15 +37,19 @@ def test_api_gateway_begin_create_or_update(self, resource_group): gateway_name="str", parameters={ "location": "str", + "properties": { + "backend": {"subnet": {"id": "str"}}, + "configurationApi": {"hostname": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "frontend": {"defaultHostname": "str"}, + "provisioningState": "str", + "targetProvisioningState": "str", + "virtualNetworkType": "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", @@ -44,11 +59,8 @@ def test_api_gateway_begin_create_or_update(self, resource_group): "lastModifiedByType": "str", }, "tags": {"str": "str"}, - "targetProvisioningState": "str", "type": "str", - "virtualNetworkType": "str", }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -61,45 +73,33 @@ def test_api_gateway_begin_update(self, resource_group): 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", + "properties": { + "backend": {"subnet": {"id": "str"}}, + "configurationApi": {"hostname": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "frontend": {"defaultHostname": "str"}, + "provisioningState": "str", + "targetProvisioningState": "str", + "virtualNetworkType": "str", + }, "sku": {"capacity": 0, "name": "str"}, "tags": {"str": "str"}, - "targetProvisioningState": "str", "type": "str", - "virtualNetworkType": "str", }, - api_version="2024-05-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_api_gateway_get(self, resource_group): - response = self.client.api_gateway.get( - resource_group_name=resource_group.name, - gateway_name="str", - api_version="2024-05-01", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_api_gateway_begin_delete(self, resource_group): response = self.client.api_gateway.begin_delete( resource_group_name=resource_group.name, gateway_name="str", - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -110,7 +110,6 @@ def test_api_gateway_begin_delete(self, resource_group): def test_api_gateway_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-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -119,9 +118,7 @@ def test_api_gateway_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_api_gateway_list(self, resource_group): - response = self.client.api_gateway.list( - api_version="2024-05-01", - ) + response = self.client.api_gateway.list() 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 index d65861fa6604..fdade871d7c4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,6 +19,17 @@ 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_api_gateway_get(self, resource_group): + response = await self.client.api_gateway.get( + resource_group_name=resource_group.name, + gateway_name="str", + ) + + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_api_gateway_begin_create_or_update(self, resource_group): @@ -28,15 +39,19 @@ async def test_api_gateway_begin_create_or_update(self, resource_group): gateway_name="str", parameters={ "location": "str", + "properties": { + "backend": {"subnet": {"id": "str"}}, + "configurationApi": {"hostname": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "frontend": {"defaultHostname": "str"}, + "provisioningState": "str", + "targetProvisioningState": "str", + "virtualNetworkType": "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", @@ -46,11 +61,8 @@ async def test_api_gateway_begin_create_or_update(self, resource_group): "lastModifiedByType": "str", }, "tags": {"str": "str"}, - "targetProvisioningState": "str", "type": "str", - "virtualNetworkType": "str", }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -65,39 +77,28 @@ async def test_api_gateway_begin_update(self, resource_group): 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", + "properties": { + "backend": {"subnet": {"id": "str"}}, + "configurationApi": {"hostname": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "frontend": {"defaultHostname": "str"}, + "provisioningState": "str", + "targetProvisioningState": "str", + "virtualNetworkType": "str", + }, "sku": {"capacity": 0, "name": "str"}, "tags": {"str": "str"}, - "targetProvisioningState": "str", "type": "str", - "virtualNetworkType": "str", }, - api_version="2024-05-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_api_gateway_get(self, resource_group): - response = await self.client.api_gateway.get( - resource_group_name=resource_group.name, - gateway_name="str", - api_version="2024-05-01", - ) - - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_api_gateway_begin_delete(self, resource_group): @@ -105,7 +106,6 @@ async def test_api_gateway_begin_delete(self, resource_group): await self.client.api_gateway.begin_delete( resource_group_name=resource_group.name, gateway_name="str", - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -117,7 +117,6 @@ async def test_api_gateway_begin_delete(self, resource_group): async def test_api_gateway_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-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -126,9 +125,7 @@ async def test_api_gateway_list_by_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_api_gateway_list(self, resource_group): - response = self.client.api_gateway.list( - api_version="2024-05-01", - ) + response = self.client.api_gateway.list() 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 index d2fa3cb95656..d760fd50d713 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,15 +20,15 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_attachment_list_by_service(self, resource_group): - response = self.client.api_issue_attachment.list_by_service( + def test_api_issue_attachment_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", - api_version="2024-05-01", + attachment_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -41,7 +41,6 @@ def test_api_issue_attachment_get_entity_tag(self, resource_group): api_id="str", issue_id="str", attachment_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -49,14 +48,27 @@ def test_api_issue_attachment_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_attachment_get(self, resource_group): - response = self.client.api_issue_attachment.get( + def test_api_issue_attachment_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"content": "str", "contentFormat": "str", "title": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -64,22 +76,15 @@ def test_api_issue_attachment_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_attachment_create_or_update(self, resource_group): - response = self.client.api_issue_attachment.create_or_update( + def test_api_issue_attachment_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", - parameters={ - "content": "str", - "contentFormat": "str", - "id": "str", - "name": "str", - "title": "str", - "type": "str", - }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -87,16 +92,13 @@ def test_api_issue_attachment_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_attachment_delete(self, resource_group): - response = self.client.api_issue_attachment.delete( + def test_api_issue_attachment_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", - attachment_id="str", - if_match="str", - api_version="2024-05-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_issue_attachment_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_attachment_operations_async.py index 5ef24d6cd936..bbb3ab735cdf 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,15 +21,15 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_attachment_list_by_service(self, resource_group): - response = self.client.api_issue_attachment.list_by_service( + async def test_api_issue_attachment_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", - api_version="2024-05-01", + attachment_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -42,7 +42,6 @@ async def test_api_issue_attachment_get_entity_tag(self, resource_group): api_id="str", issue_id="str", attachment_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -50,14 +49,27 @@ async def test_api_issue_attachment_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_attachment_get(self, resource_group): - response = await self.client.api_issue_attachment.get( + async def test_api_issue_attachment_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"content": "str", "contentFormat": "str", "title": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -65,22 +77,15 @@ async def test_api_issue_attachment_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_attachment_create_or_update(self, resource_group): - response = await self.client.api_issue_attachment.create_or_update( + async def test_api_issue_attachment_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", - parameters={ - "content": "str", - "contentFormat": "str", - "id": "str", - "name": "str", - "title": "str", - "type": "str", - }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -88,16 +93,13 @@ async def test_api_issue_attachment_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_attachment_delete(self, resource_group): - response = await self.client.api_issue_attachment.delete( + async def test_api_issue_attachment_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", - attachment_id="str", - if_match="str", - api_version="2024-05-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_comment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations.py index b47d46e4e27f..7f939bd484f3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,15 +20,15 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_comment_list_by_service(self, resource_group): - response = self.client.api_issue_comment.list_by_service( + def test_api_issue_comment_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", - api_version="2024-05-01", + comment_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -41,7 +41,6 @@ def test_api_issue_comment_get_entity_tag(self, resource_group): api_id="str", issue_id="str", comment_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -49,14 +48,27 @@ def test_api_issue_comment_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_comment_get(self, resource_group): - response = self.client.api_issue_comment.get( + def test_api_issue_comment_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"text": "str", "userId": "str", "createdDate": "2020-02-20 00:00:00"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -64,22 +76,15 @@ def test_api_issue_comment_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_comment_create_or_update(self, resource_group): - response = self.client.api_issue_comment.create_or_update( + def test_api_issue_comment_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", - parameters={ - "createdDate": "2020-02-20 00:00:00", - "id": "str", - "name": "str", - "text": "str", - "type": "str", - "userId": "str", - }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -87,16 +92,13 @@ def test_api_issue_comment_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_comment_delete(self, resource_group): - response = self.client.api_issue_comment.delete( + def test_api_issue_comment_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", - comment_id="str", - if_match="str", - api_version="2024-05-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_issue_comment_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_comment_operations_async.py index 86e810e48e7c..70643b1a5e25 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,15 +21,15 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_comment_list_by_service(self, resource_group): - response = self.client.api_issue_comment.list_by_service( + async def test_api_issue_comment_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", - api_version="2024-05-01", + comment_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -42,7 +42,6 @@ async def test_api_issue_comment_get_entity_tag(self, resource_group): api_id="str", issue_id="str", comment_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -50,14 +49,27 @@ async def test_api_issue_comment_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_comment_get(self, resource_group): - response = await self.client.api_issue_comment.get( + async def test_api_issue_comment_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"text": "str", "userId": "str", "createdDate": "2020-02-20 00:00:00"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -65,22 +77,15 @@ async def test_api_issue_comment_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_comment_create_or_update(self, resource_group): - response = await self.client.api_issue_comment.create_or_update( + async def test_api_issue_comment_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", - parameters={ - "createdDate": "2020-02-20 00:00:00", - "id": "str", - "name": "str", - "text": "str", - "type": "str", - "userId": "str", - }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -88,16 +93,13 @@ async def test_api_issue_comment_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_comment_delete(self, resource_group): - response = await self.client.api_issue_comment.delete( + async def test_api_issue_comment_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", - comment_id="str", - if_match="str", - api_version="2024-05-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_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations.py index 030361ebc0a2..0aeb3622d1a4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_api_issue_get_entity_tag(self, resource_group): - response = self.client.api_issue.get_entity_tag( + def test_api_issue_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_api_issue_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_issue_get(self, resource_group): - response = self.client.api_issue.get( + def test_api_issue_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-05-01", ) # please add some check logic here by yourself @@ -68,17 +53,26 @@ def test_api_issue_create_or_update(self, resource_group): 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", + "properties": { + "description": "str", + "title": "str", + "userId": "str", + "apiId": "str", + "createdDate": "2020-02-20 00:00:00", + "state": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "userId": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -92,16 +86,18 @@ def test_api_issue_update(self, resource_group): 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", + "properties": { + "apiId": "str", + "createdDate": "2020-02-20 00:00:00", + "description": "str", + "state": "str", + "title": "str", + "userId": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -115,9 +111,21 @@ def test_api_issue_delete(self, resource_group): service_name="str", api_id="str", issue_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_issue_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", + ) + 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_issue_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_issue_operations_async.py index 421785f1c6ce..128f15c66e7a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_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-05-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_api_issue_get_entity_tag(self, resource_group): - response = await self.client.api_issue.get_entity_tag( + async def test_api_issue_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_api_issue_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_issue_get(self, resource_group): - response = await self.client.api_issue.get( + async def test_api_issue_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-05-01", ) # please add some check logic here by yourself @@ -69,17 +54,26 @@ async def test_api_issue_create_or_update(self, resource_group): 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", + "properties": { + "description": "str", + "title": "str", + "userId": "str", + "apiId": "str", + "createdDate": "2020-02-20 00:00:00", + "state": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "userId": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -93,16 +87,18 @@ async def test_api_issue_update(self, resource_group): 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", + "properties": { + "apiId": "str", + "createdDate": "2020-02-20 00:00:00", + "description": "str", + "state": "str", + "title": "str", + "userId": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -116,9 +112,21 @@ async def test_api_issue_delete(self, resource_group): service_name="str", api_id="str", issue_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_issue_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", + ) + 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_gateway_skus_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_management_gateway_skus_operations.py index 59e8ff045bbd..c4a84314d6bc 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_api_management_gateway_skus_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-05-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 index 7dd08286ae3c..43ae19ad687e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_api_management_gateway_skus_list_available_skus(self, resource_gr response = self.client.api_management_gateway_skus.list_available_skus( resource_group_name=resource_group.name, gateway_name="str", - api_version="2024-05-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 index 5132e75f5469..11cb9e9a0669 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,9 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_api_management_operations_list(self, resource_group): - response = self.client.api_management_operations.list( - api_version="2024-05-01", - ) + response = self.client.api_management_operations.list() 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 index 7bc366aca259..186ed1de4300 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -22,9 +22,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_api_management_operations_list(self, resource_group): - response = self.client.api_management_operations.list( - api_version="2024-05-01", - ) + response = self.client.api_management_operations.list() 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 index cf6ef3928e0d..72baa4fd4778 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,40 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_management_service_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-05-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_api_management_service_begin_backup(self, resource_group): - response = self.client.api_management_service.begin_backup( + def test_api_management_service_get(self, resource_group): + response = self.client.api_management_service.get( 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-05-01", - ).result() # call '.result()' to poll until service return final result + ) # please add some check logic here by yourself # ... @@ -66,63 +37,101 @@ def test_api_management_service_begin_create_or_update(self, resource_group): service_name="str", parameters={ "location": "str", - "publisherEmail": "str", - "publisherName": "str", + "properties": { + "publisherEmail": "str", + "publisherName": "str", + "additionalLocations": [ + { + "location": "str", + "sku": {"capacity": 0, "name": "str"}, + "disableGateway": bool, + "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": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "customProperties": {"str": "str"}, + "developerPortalStatus": "str", + "developerPortalUrl": "str", + "disableGateway": bool, + "enableClientCertificate": bool, + "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": bool, + "encodedCertificate": "str", + "identityClientId": "str", + "keyVaultId": "str", + "negotiateClientCertificate": bool, + } + ], + "legacyPortalStatus": "str", + "managementApiUrl": "str", + "natGatewayState": "str", + "notificationSenderEmail": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "portalUrl": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "type": "str", + } + ], + "privateIPAddresses": ["str"], + "provisioningState": "str", + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "publicNetworkAccess": "str", + "releaseChannel": "str", + "restore": bool, + "scmUrl": "str", + "targetProvisioningState": "str", + "virtualNetworkConfiguration": {"subnetResourceId": "str", "subnetname": "str", "vnetid": "str"}, + "virtualNetworkType": "str", + "zoneRedundant": bool, + }, "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", @@ -130,36 +139,7 @@ def test_api_management_service_begin_create_or_update(self, resource_group): "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", @@ -169,13 +149,9 @@ def test_api_management_service_begin_create_or_update(self, resource_group): "lastModifiedByType": "str", }, "tags": {"str": "str"}, - "targetProvisioningState": "str", "type": "str", - "virtualNetworkConfiguration": {"subnetResourceId": "str", "subnetname": "str", "vnetid": "str"}, - "virtualNetworkType": "str", "zones": ["str"], }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -188,60 +164,7 @@ def test_api_management_service_begin_update(self, resource_group): 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", @@ -249,47 +172,105 @@ def test_api_management_service_begin_update(self, resource_group): "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", + "properties": { + "additionalLocations": [ + { + "location": "str", + "sku": {"capacity": 0, "name": "str"}, + "disableGateway": bool, + "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": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "customProperties": {"str": "str"}, + "developerPortalStatus": "str", + "developerPortalUrl": "str", + "disableGateway": bool, + "enableClientCertificate": bool, + "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": bool, + "encodedCertificate": "str", + "identityClientId": "str", + "keyVaultId": "str", + "negotiateClientCertificate": bool, + } + ], + "legacyPortalStatus": "str", + "managementApiUrl": "str", + "natGatewayState": "str", + "notificationSenderEmail": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "portalUrl": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "type": "str", + } + ], + "privateIPAddresses": ["str"], + "provisioningState": "str", + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "publicNetworkAccess": "str", + "publisherEmail": "str", + "publisherName": "str", + "releaseChannel": "str", + "restore": bool, + "scmUrl": "str", + "targetProvisioningState": "str", + "virtualNetworkConfiguration": {"subnetResourceId": "str", "subnetname": "str", "vnetid": "str"}, + "virtualNetworkType": "str", + "zoneRedundant": bool, + }, "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-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -297,23 +278,47 @@ def test_api_management_service_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_management_service_get(self, resource_group): - response = self.client.api_management_service.get( + def test_api_management_service_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-05-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_api_management_service_list_by_resource_group(self, resource_group): + response = self.client.api_management_service.list_by_resource_group( + resource_group_name=resource_group.name, ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_management_service_list(self, resource_group): + response = self.client.api_management_service.list() + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_management_service_begin_delete(self, resource_group): - response = self.client.api_management_service.begin_delete( + def test_api_management_service_begin_restore(self, resource_group): + response = self.client.api_management_service.begin_restore( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + parameters={ + "backupName": "str", + "containerName": "str", + "storageAccount": "str", + "accessKey": "str", + "accessType": "str", + "clientId": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -321,11 +326,18 @@ def test_api_management_service_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_management_service_begin_migrate_to_stv2(self, resource_group): - response = self.client.api_management_service.begin_migrate_to_stv2( + def test_api_management_service_begin_backup(self, resource_group): + response = self.client.api_management_service.begin_backup( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + parameters={ + "backupName": "str", + "containerName": "str", + "storageAccount": "str", + "accessKey": "str", + "accessType": "str", + "clientId": "str", + }, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -333,53 +345,53 @@ def test_api_management_service_begin_migrate_to_stv2(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_management_service_list_by_resource_group(self, resource_group): - response = self.client.api_management_service.list_by_resource_group( + def test_api_management_service_begin_migrate_to_stv2(self, resource_group): + response = self.client.api_management_service.begin_migrate_to_stv2( resource_group_name=resource_group.name, - api_version="2024-05-01", - ) - result = [r for r in response] + service_name="str", + ).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_api_management_service_list(self, resource_group): - response = self.client.api_management_service.list( - api_version="2024-05-01", + def test_api_management_service_get_sso_token(self, resource_group): + response = self.client.api_management_service.get_sso_token( + resource_group_name=resource_group.name, + service_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_management_service_get_sso_token(self, resource_group): - response = self.client.api_management_service.get_sso_token( + def test_api_management_service_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-05-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_api_management_service_check_name_availability(self, resource_group): - response = self.client.api_management_service.check_name_availability( - parameters={"name": "str"}, - api_version="2024-05-01", - ) + def test_api_management_service_begin_refresh_hostnames(self, resource_group): + response = self.client.api_management_service.begin_refresh_hostnames( + resource_group_name=resource_group.name, + service_name="str", + ).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_api_management_service_get_domain_ownership_identifier(self, resource_group): - response = self.client.api_management_service.get_domain_ownership_identifier( - api_version="2024-05-01", + def test_api_management_service_check_name_availability(self, resource_group): + response = self.client.api_management_service.check_name_availability( + parameters={"name": "str"}, ) # please add some check logic here by yourself @@ -387,12 +399,8 @@ def test_api_management_service_get_domain_ownership_identifier(self, resource_g @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_management_service_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-05-01", - ).result() # call '.result()' to poll until service return final result + def test_api_management_service_get_domain_ownership_identifier(self, resource_group): + response = self.client.api_management_service.get_domain_ownership_identifier() # 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 index a21ea2202196..098a57c561f0 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,44 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_management_service_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-05-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_api_management_service_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-05-01", - ) - ).result() # call '.result()' to poll until service return final result + async def test_api_management_service_get(self, resource_group): + response = await self.client.api_management_service.get( + resource_group_name=resource_group.name, + service_name="str", + ) # please add some check logic here by yourself # ... @@ -72,63 +39,105 @@ async def test_api_management_service_begin_create_or_update(self, resource_grou service_name="str", parameters={ "location": "str", - "publisherEmail": "str", - "publisherName": "str", + "properties": { + "publisherEmail": "str", + "publisherName": "str", + "additionalLocations": [ + { + "location": "str", + "sku": {"capacity": 0, "name": "str"}, + "disableGateway": bool, + "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": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "customProperties": {"str": "str"}, + "developerPortalStatus": "str", + "developerPortalUrl": "str", + "disableGateway": bool, + "enableClientCertificate": bool, + "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": bool, + "encodedCertificate": "str", + "identityClientId": "str", + "keyVaultId": "str", + "negotiateClientCertificate": bool, + } + ], + "legacyPortalStatus": "str", + "managementApiUrl": "str", + "natGatewayState": "str", + "notificationSenderEmail": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "portalUrl": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "type": "str", + } + ], + "privateIPAddresses": ["str"], + "provisioningState": "str", + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "publicNetworkAccess": "str", + "releaseChannel": "str", + "restore": bool, + "scmUrl": "str", + "targetProvisioningState": "str", + "virtualNetworkConfiguration": { + "subnetResourceId": "str", + "subnetname": "str", + "vnetid": "str", + }, + "virtualNetworkType": "str", + "zoneRedundant": bool, + }, "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", @@ -136,36 +145,7 @@ async def test_api_management_service_begin_create_or_update(self, resource_grou "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", @@ -175,13 +155,9 @@ async def test_api_management_service_begin_create_or_update(self, resource_grou "lastModifiedByType": "str", }, "tags": {"str": "str"}, - "targetProvisioningState": "str", "type": "str", - "virtualNetworkConfiguration": {"subnetResourceId": "str", "subnetname": "str", "vnetid": "str"}, - "virtualNetworkType": "str", "zones": ["str"], }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -196,60 +172,7 @@ async def test_api_management_service_begin_update(self, resource_group): 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", @@ -257,47 +180,109 @@ async def test_api_management_service_begin_update(self, resource_group): "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", + "properties": { + "additionalLocations": [ + { + "location": "str", + "sku": {"capacity": 0, "name": "str"}, + "disableGateway": bool, + "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": "str"}, + "createdAtUtc": "2020-02-20 00:00:00", + "customProperties": {"str": "str"}, + "developerPortalStatus": "str", + "developerPortalUrl": "str", + "disableGateway": bool, + "enableClientCertificate": bool, + "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": bool, + "encodedCertificate": "str", + "identityClientId": "str", + "keyVaultId": "str", + "negotiateClientCertificate": bool, + } + ], + "legacyPortalStatus": "str", + "managementApiUrl": "str", + "natGatewayState": "str", + "notificationSenderEmail": "str", + "outboundPublicIPAddresses": ["str"], + "platformVersion": "str", + "portalUrl": "str", + "privateEndpointConnections": [ + { + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "type": "str", + } + ], + "privateIPAddresses": ["str"], + "provisioningState": "str", + "publicIPAddresses": ["str"], + "publicIpAddressId": "str", + "publicNetworkAccess": "str", + "publisherEmail": "str", + "publisherName": "str", + "releaseChannel": "str", + "restore": bool, + "scmUrl": "str", + "targetProvisioningState": "str", + "virtualNetworkConfiguration": { + "subnetResourceId": "str", + "subnetname": "str", + "vnetid": "str", + }, + "virtualNetworkType": "str", + "zoneRedundant": bool, + }, "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-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -306,24 +291,71 @@ async def test_api_management_service_begin_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_management_service_get(self, resource_group): - response = await self.client.api_management_service.get( + async def test_api_management_service_begin_delete(self, resource_group): + response = await ( + await self.client.api_management_service.begin_delete( + resource_group_name=resource_group.name, + service_name="str", + ) + ).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_api_management_service_list_by_resource_group(self, resource_group): + response = self.client.api_management_service.list_by_resource_group( resource_group_name=resource_group.name, - service_name="str", - api_version="2024-05-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_api_management_service_list(self, resource_group): + response = self.client.api_management_service.list() + 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_api_management_service_begin_delete(self, resource_group): + async def test_api_management_service_begin_restore(self, resource_group): response = await ( - await self.client.api_management_service.begin_delete( + await self.client.api_management_service.begin_restore( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + parameters={ + "backupName": "str", + "containerName": "str", + "storageAccount": "str", + "accessKey": "str", + "accessType": "str", + "clientId": "str", + }, + ) + ).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_api_management_service_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": "str", + "clientId": "str", + }, ) ).result() # call '.result()' to poll until service return final result @@ -337,7 +369,6 @@ async def test_api_management_service_begin_migrate_to_stv2(self, resource_group await self.client.api_management_service.begin_migrate_to_stv2( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -346,33 +377,37 @@ async def test_api_management_service_begin_migrate_to_stv2(self, resource_group @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_management_service_list_by_resource_group(self, resource_group): - response = self.client.api_management_service.list_by_resource_group( + async def test_api_management_service_get_sso_token(self, resource_group): + response = await self.client.api_management_service.get_sso_token( resource_group_name=resource_group.name, - api_version="2024-05-01", + service_name="str", ) - 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_api_management_service_list(self, resource_group): - response = self.client.api_management_service.list( - api_version="2024-05-01", - ) - result = [r async for r in response] + async def test_api_management_service_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", + ) + ).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_api_management_service_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-05-01", - ) + async def test_api_management_service_begin_refresh_hostnames(self, resource_group): + response = await ( + await self.client.api_management_service.begin_refresh_hostnames( + resource_group_name=resource_group.name, + service_name="str", + ) + ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself # ... @@ -382,7 +417,6 @@ async def test_api_management_service_get_sso_token(self, resource_group): async def test_api_management_service_check_name_availability(self, resource_group): response = await self.client.api_management_service.check_name_availability( parameters={"name": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -391,23 +425,7 @@ async def test_api_management_service_check_name_availability(self, resource_gro @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_api_management_service_get_domain_ownership_identifier(self, resource_group): - response = await self.client.api_management_service.get_domain_ownership_identifier( - api_version="2024-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_api_management_service_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-05-01", - ) - ).result() # call '.result()' to poll until service return final result + response = await self.client.api_management_service.get_domain_ownership_identifier() # 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 index 891469875297..04221ca972d3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_api_management_service_skus_list_available_service_skus(self, resource_ response = self.client.api_management_service_skus.list_available_service_skus( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-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 index e183a49dc3a1..46aa54613089 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_api_management_service_skus_list_available_service_skus(self, res response = self.client.api_management_service_skus.list_available_service_skus( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-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 index 04ebf496b394..ef05540295a7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,9 +21,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_api_management_skus_list(self, resource_group): - response = self.client.api_management_skus.list( - api_version="2024-05-01", - ) + response = self.client.api_management_skus.list() 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 index 37bb3a1d6b2a..0214c8d6f5f4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -22,9 +22,7 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async async def test_api_management_skus_list(self, resource_group): - response = self.client.api_management_skus.list( - api_version="2024-05-01", - ) + response = self.client.api_management_skus.list() 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 index 6239d5e109bd..5d33c4abcf54 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_api_management_workspace_link_get(self, resource_group): resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-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 index 6664a0989dd7..f31574b2a70e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_api_management_workspace_link_get(self, resource_group): resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-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 index 5b5cbe81af50..12bf35b8d87f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_api_management_workspace_links_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-05-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 index 6cb4bd3cab21..1f40a5822fdf 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_api_management_workspace_links_list_by_service(self, resource_gro response = self.client.api_management_workspace_links.list_by_service( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-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 index f4222651a3cc..99982e770c62 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_operation_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_api_operation_get_entity_tag(self, resource_group): - response = self.client.api_operation.get_entity_tag( + def test_api_operation_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_api_operation_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_operation_get(self, resource_group): - response = self.client.api_operation.get( + def test_api_operation_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-05-01", ) # please add some check logic here by yourself @@ -68,78 +53,15 @@ def test_api_operation_create_or_update(self, resource_group): api_id="str", operation_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", - "method": "str", "name": "str", - "policies": "str", - "request": { + "properties": { + "displayName": "str", + "method": "str", + "urlTemplate": "str", "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, + "policies": "str", + "request": { "description": "str", "headers": [ { @@ -156,6 +78,21 @@ def test_api_operation_create_or_update(self, resource_group): "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", @@ -186,85 +123,12 @@ def test_api_operation_create_or_update(self, resource_group): "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-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_api_operation_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": [ + }, + "responses": [ { - "name": "str", - "type": "str", - "defaultValue": "str", + "statusCode": 0, "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": [ + "headers": [ { "name": "str", "type": "str", @@ -284,14 +148,89 @@ def test_api_operation_update(self, resource_group): "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"], } ], }, - "responses": [ - { - "statusCode": 0, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_operation_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", + parameters={ + "properties": { + "description": "str", + "displayName": "str", + "method": "str", + "policies": "str", + "request": { "description": "str", "headers": [ { @@ -308,6 +247,21 @@ def test_api_operation_update(self, resource_group): "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", @@ -338,26 +292,88 @@ def test_api_operation_update(self, resource_group): "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", + }, + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -371,9 +387,21 @@ def test_api_operation_delete(self, resource_group): service_name="str", api_id="str", operation_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_operation_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", + ) + 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_operation_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_operations_async.py index 7b9939618409..b1d4ae4b7a50 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_operation_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-05-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_api_operation_get_entity_tag(self, resource_group): - response = await self.client.api_operation.get_entity_tag( + async def test_api_operation_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_api_operation_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_operation_get(self, resource_group): - response = await self.client.api_operation.get( + async def test_api_operation_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-05-01", ) # please add some check logic here by yourself @@ -69,78 +54,15 @@ async def test_api_operation_create_or_update(self, resource_group): api_id="str", operation_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", - "method": "str", "name": "str", - "policies": "str", - "request": { + "properties": { + "displayName": "str", + "method": "str", + "urlTemplate": "str", "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, + "policies": "str", + "request": { "description": "str", "headers": [ { @@ -157,6 +79,21 @@ async def test_api_operation_create_or_update(self, resource_group): "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", @@ -187,85 +124,12 @@ async def test_api_operation_create_or_update(self, resource_group): "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-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_api_operation_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": [ + }, + "responses": [ { - "name": "str", - "type": "str", - "defaultValue": "str", + "statusCode": 0, "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": [ + "headers": [ { "name": "str", "type": "str", @@ -285,14 +149,89 @@ async def test_api_operation_update(self, resource_group): "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"], } ], }, - "responses": [ - { - "statusCode": 0, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_operation_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", + parameters={ + "properties": { + "description": "str", + "displayName": "str", + "method": "str", + "policies": "str", + "request": { "description": "str", "headers": [ { @@ -309,6 +248,21 @@ async def test_api_operation_update(self, resource_group): "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", @@ -339,26 +293,88 @@ async def test_api_operation_update(self, resource_group): "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", + }, + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -372,9 +388,21 @@ async def test_api_operation_delete(self, resource_group): service_name="str", api_id="str", operation_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_operation_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", + ) + 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_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_operation_policy_operations.py index 37a61ac16fa9..65161250b58f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_operation_policy_list_by_operation(self, resource_group): - response = self.client.api_operation_policy.list_by_operation( + def test_api_operation_policy_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", - api_version="2024-05-01", + policy_id="str", ) # please add some check logic here by yourself @@ -41,7 +41,6 @@ def test_api_operation_policy_get_entity_tag(self, resource_group): api_id="str", operation_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -49,14 +48,27 @@ def test_api_operation_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_operation_policy_get(self, resource_group): - response = self.client.api_operation_policy.get( + def test_api_operation_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -64,15 +76,15 @@ def test_api_operation_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_operation_policy_create_or_update(self, resource_group): - response = self.client.api_operation_policy.create_or_update( + def test_api_operation_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -80,15 +92,12 @@ def test_api_operation_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_operation_policy_delete(self, resource_group): - response = self.client.api_operation_policy.delete( + def test_api_operation_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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 index 884e299d3c35..5a9b84e4a045 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_operation_policy_list_by_operation(self, resource_group): - response = await self.client.api_operation_policy.list_by_operation( + async def test_api_operation_policy_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", - api_version="2024-05-01", + policy_id="str", ) # please add some check logic here by yourself @@ -42,7 +42,6 @@ async def test_api_operation_policy_get_entity_tag(self, resource_group): api_id="str", operation_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -50,14 +49,27 @@ async def test_api_operation_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_operation_policy_get(self, resource_group): - response = await self.client.api_operation_policy.get( + async def test_api_operation_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -65,15 +77,15 @@ async def test_api_operation_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_operation_policy_create_or_update(self, resource_group): - response = await self.client.api_operation_policy.create_or_update( + async def test_api_operation_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -81,15 +93,12 @@ async def test_api_operation_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_operation_policy_delete(self, resource_group): - response = await self.client.api_operation_policy.delete( + async def test_api_operation_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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 index 61aa0159f690..9f2917909c66 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_api_get_entity_tag(self, resource_group): - response = self.client.api.get_entity_tag( + def test_api_get(self, resource_group): + response = self.client.api.get( resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_api_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_get(self, resource_group): - response = self.client.api.get( + def test_api_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-05-01", ) # please add some check logic here by yourself @@ -64,47 +50,50 @@ def test_api_begin_create_or_update(self, resource_group): service_name="str", api_id="str", parameters={ - "apiRevision": "str", - "apiRevisionDescription": "str", - "apiType": "str", - "apiVersion": "str", - "apiVersionDescription": "str", - "apiVersionSet": { + "properties": { + "path": "str", + "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", - "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"}, + "displayName": "str", + "format": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "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-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -117,34 +106,38 @@ def test_api_update(self, resource_group): 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", + "properties": { + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -157,20 +150,30 @@ def test_api_begin_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ).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_api_list_by_service(self, resource_group): + response = self.client.api.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_api_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-05-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 index f7c38649d260..392beff04bbe 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_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-05-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_api_get_entity_tag(self, resource_group): - response = await self.client.api.get_entity_tag( + async def test_api_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_api_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_get(self, resource_group): - response = await self.client.api.get( + async def test_api_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-05-01", ) # please add some check logic here by yourself @@ -66,19 +52,69 @@ async def test_api_begin_create_or_update(self, resource_group): service_name="str", api_id="str", parameters={ + "properties": { + "path": "str", + "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"}, + "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"}, + } + }, + ) + ).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_api_update(self, resource_group): + response = await self.client.api.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + parameters={ + "properties": { "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"}, @@ -91,65 +127,20 @@ async def test_api_begin_create_or_update(self, resource_group): "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-05-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_api_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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -163,21 +154,31 @@ async def test_api_begin_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) ).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_api_list_by_service(self, resource_group): + response = self.client.api.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_api_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-05-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 index c047fc4aa653..cb525f522c2e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,12 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_policy_list_by_api(self, resource_group): - response = self.client.api_policy.list_by_api( + def test_api_policy_get(self, resource_group): + response = self.client.api_policy.get( resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-01", + policy_id="str", ) # please add some check logic here by yourself @@ -39,7 +39,6 @@ def test_api_policy_get_entity_tag(self, resource_group): service_name="str", api_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,26 @@ def test_api_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_policy_get(self, resource_group): - response = self.client.api_policy.get( + def test_api_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -61,14 +73,14 @@ def test_api_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_policy_create_or_update(self, resource_group): - response = self.client.api_policy.create_or_update( + def test_api_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -76,14 +88,11 @@ def test_api_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_policy_delete(self, resource_group): - response = self.client.api_policy.delete( + def test_api_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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 index ba7e5847c070..7024ab54f863 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,12 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_policy_list_by_api(self, resource_group): - response = await self.client.api_policy.list_by_api( + async def test_api_policy_get(self, resource_group): + response = await self.client.api_policy.get( resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-01", + policy_id="str", ) # please add some check logic here by yourself @@ -40,7 +40,6 @@ async def test_api_policy_get_entity_tag(self, resource_group): service_name="str", api_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,26 @@ async def test_api_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_policy_get(self, resource_group): - response = await self.client.api_policy.get( + async def test_api_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -62,14 +74,14 @@ async def test_api_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_policy_create_or_update(self, resource_group): - response = await self.client.api_policy.create_or_update( + async def test_api_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -77,14 +89,11 @@ async def test_api_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_policy_delete(self, resource_group): - response = await self.client.api_policy.delete( + async def test_api_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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 index a96d6d6e4dfa..ab0765af9999 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_api_product_list_by_apis(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-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 index 56a7f0515bf4..7164aba27a96 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_api_product_list_by_apis(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-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 index 071c1ccdd6b4..ae65151bfe57 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_release_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_api_release_get_entity_tag(self, resource_group): - response = self.client.api_release.get_entity_tag( + def test_api_release_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_api_release_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_release_get(self, resource_group): - response = self.client.api_release.get( + def test_api_release_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-05-01", ) # please add some check logic here by yourself @@ -68,15 +53,24 @@ def test_api_release_create_or_update(self, resource_group): api_id="str", release_id="str", parameters={ - "apiId": "str", - "createdDateTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "notes": "str", + "properties": { + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "notes": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -90,17 +84,27 @@ def test_api_release_update(self, resource_group): 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", + "properties": { + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "notes": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -114,9 +118,21 @@ def test_api_release_delete(self, resource_group): service_name="str", api_id="str", release_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_release_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", + ) + 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_release_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_release_operations_async.py index bda79ff8870d..9215bedec8e4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_release_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-05-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_api_release_get_entity_tag(self, resource_group): - response = await self.client.api_release.get_entity_tag( + async def test_api_release_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_api_release_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_release_get(self, resource_group): - response = await self.client.api_release.get( + async def test_api_release_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-05-01", ) # please add some check logic here by yourself @@ -69,15 +54,24 @@ async def test_api_release_create_or_update(self, resource_group): api_id="str", release_id="str", parameters={ - "apiId": "str", - "createdDateTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "notes": "str", + "properties": { + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "notes": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -91,17 +85,27 @@ async def test_api_release_update(self, resource_group): 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", + "properties": { + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "notes": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -115,9 +119,21 @@ async def test_api_release_delete(self, resource_group): service_name="str", api_id="str", release_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_release_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", + ) + 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_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_revision_operations.py index affb193bd59e..209d435ec504 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_api_revision_list_by_service(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-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 index a11f28cdd786..3bac87b546ce 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_api_revision_list_by_service(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-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 index 4a44a4c40193..656f06998c28 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_schema_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_api_schema_get_entity_tag(self, resource_group): - response = self.client.api_schema.get_entity_tag( + def test_api_schema_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_api_schema_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_schema_get(self, resource_group): - response = self.client.api_schema.get( + def test_api_schema_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-05-01", ) # please add some check logic here by yourself @@ -68,16 +53,23 @@ def test_api_schema_begin_create_or_update(self, resource_group): api_id="str", schema_id="str", parameters={ - "components": {}, - "contentType": "str", - "definitions": {}, "id": "str", "name": "str", - "provisioningState": "str", + "properties": { + "contentType": "str", + "document": {"components": {}, "definitions": {}, "value": "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", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -91,9 +83,21 @@ def test_api_schema_delete(self, resource_group): service_name="str", api_id="str", schema_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_schema_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", + ) + 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_schema_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_schema_operations_async.py index d638d5b93116..38537edb0d28 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_schema_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-05-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_api_schema_get_entity_tag(self, resource_group): - response = await self.client.api_schema.get_entity_tag( + async def test_api_schema_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_api_schema_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_schema_get(self, resource_group): - response = await self.client.api_schema.get( + async def test_api_schema_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-05-01", ) # please add some check logic here by yourself @@ -70,16 +55,23 @@ async def test_api_schema_begin_create_or_update(self, resource_group): api_id="str", schema_id="str", parameters={ - "components": {}, - "contentType": "str", - "definitions": {}, "id": "str", "name": "str", - "provisioningState": "str", + "properties": { + "contentType": "str", + "document": {"components": {}, "definitions": {}, "value": "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", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -94,9 +86,21 @@ async def test_api_schema_delete(self, resource_group): service_name="str", api_id="str", schema_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_schema_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", + ) + 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_tag_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations.py index 63011e1f6529..1aebe201b483 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_tag_description_list_by_service(self, resource_group): - response = self.client.api_tag_description.list_by_service( + def test_api_tag_description_get(self, resource_group): + response = self.client.api_tag_description.get( resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-01", + tag_description_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -39,7 +39,6 @@ def test_api_tag_description_get_entity_tag(self, resource_group): service_name="str", api_id="str", tag_description_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,15 @@ def test_api_tag_description_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_tag_description_get(self, resource_group): - response = self.client.api_tag_description.get( + def test_api_tag_description_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", - api_version="2024-05-01", + parameters={ + "properties": {"description": "str", "externalDocsDescription": "str", "externalDocsUrl": "str"} + }, ) # please add some check logic here by yourself @@ -61,14 +62,14 @@ def test_api_tag_description_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_tag_description_create_or_update(self, resource_group): - response = self.client.api_tag_description.create_or_update( + def test_api_tag_description_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", - parameters={"description": "str", "externalDocsDescription": "str", "externalDocsUrl": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -76,15 +77,12 @@ def test_api_tag_description_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_tag_description_delete(self, resource_group): - response = self.client.api_tag_description.delete( + def test_api_tag_description_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", - tag_description_id="str", - if_match="str", - api_version="2024-05-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_tag_description_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tag_description_operations_async.py index 68758367a92f..88b55372dbd5 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_tag_description_list_by_service(self, resource_group): - response = self.client.api_tag_description.list_by_service( + async def test_api_tag_description_get(self, resource_group): + response = await self.client.api_tag_description.get( resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-01", + tag_description_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +40,6 @@ async def test_api_tag_description_get_entity_tag(self, resource_group): service_name="str", api_id="str", tag_description_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,15 @@ async def test_api_tag_description_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_tag_description_get(self, resource_group): - response = await self.client.api_tag_description.get( + async def test_api_tag_description_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", - api_version="2024-05-01", + parameters={ + "properties": {"description": "str", "externalDocsDescription": "str", "externalDocsUrl": "str"} + }, ) # please add some check logic here by yourself @@ -62,14 +63,14 @@ async def test_api_tag_description_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_tag_description_create_or_update(self, resource_group): - response = await self.client.api_tag_description.create_or_update( + async def test_api_tag_description_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", - parameters={"description": "str", "externalDocsDescription": "str", "externalDocsUrl": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -77,15 +78,12 @@ async def test_api_tag_description_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_tag_description_delete(self, resource_group): - response = await self.client.api_tag_description.delete( + async def test_api_tag_description_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", - tag_description_id="str", - if_match="str", - api_version="2024-05-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_tool_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tool_operations.py new file mode 100644 index 000000000000..ac84cdbb2902 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tool_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) Python 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 TestApiManagementApiToolOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_tool_get(self, resource_group): + response = self.client.api_tool.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_tool_get_entity_tag(self, resource_group): + response = self.client.api_tool.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_tool_create_or_update(self, resource_group): + response = self.client.api_tool.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"description": "str", "displayName": "str", "operationId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_tool_update(self, resource_group): + response = self.client.api_tool.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"description": "str", "displayName": "str", "operationId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_tool_delete(self, resource_group): + response = self.client.api_tool.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_tool_list_by_api(self, resource_group): + response = self.client.api_tool.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + ) + 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_tool_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tool_operations_async.py new file mode 100644 index 000000000000..4a9394c005a5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_tool_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) Python 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 TestApiManagementApiToolOperationsAsync(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_api_tool_get(self, resource_group): + response = await self.client.api_tool.get( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_tool_get_entity_tag(self, resource_group): + response = await self.client.api_tool.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_tool_create_or_update(self, resource_group): + response = await self.client.api_tool.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"description": "str", "displayName": "str", "operationId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_tool_update(self, resource_group): + response = await self.client.api_tool.update( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"description": "str", "displayName": "str", "operationId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_tool_delete(self, resource_group): + response = await self.client.api_tool.delete( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + tool_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_tool_list_by_api(self, resource_group): + response = self.client.api_tool.list_by_api( + resource_group_name=resource_group.name, + service_name="str", + api_id="str", + ) + 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_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations.py index be5512d9849f..7064e0d7a12f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_version_set_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_api_version_set_get_entity_tag(self, resource_group): - response = self.client.api_version_set.get_entity_tag( + def test_api_version_set_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-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_api_version_set_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_version_set_get(self, resource_group): - response = self.client.api_version_set.get( + def test_api_version_set_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-05-01", ) # please add some check logic here by yourself @@ -64,16 +50,25 @@ def test_api_version_set_create_or_update(self, resource_group): service_name="str", version_set_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", "name": "str", + "properties": { + "displayName": "str", + "versioningScheme": "str", + "description": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "versionHeaderName": "str", - "versionQueryName": "str", - "versioningScheme": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -86,15 +81,17 @@ def test_api_version_set_update(self, resource_group): 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", + "properties": { + "description": "str", + "displayName": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -107,9 +104,20 @@ def test_api_version_set_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", version_set_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_api_version_set_list_by_service(self, resource_group): + response = self.client.api_version_set.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_version_set_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_version_set_operations_async.py index ab7b1eb7bdec..24981a27d231 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_version_set_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-05-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_api_version_set_get_entity_tag(self, resource_group): - response = await self.client.api_version_set.get_entity_tag( + async def test_api_version_set_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_api_version_set_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_version_set_get(self, resource_group): - response = await self.client.api_version_set.get( + async def test_api_version_set_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-05-01", ) # please add some check logic here by yourself @@ -65,16 +51,25 @@ async def test_api_version_set_create_or_update(self, resource_group): service_name="str", version_set_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", "name": "str", + "properties": { + "displayName": "str", + "versioningScheme": "str", + "description": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "versionHeaderName": "str", - "versionQueryName": "str", - "versioningScheme": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -87,15 +82,17 @@ async def test_api_version_set_update(self, resource_group): 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", + "properties": { + "description": "str", + "displayName": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -108,9 +105,20 @@ async def test_api_version_set_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", version_set_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_api_version_set_list_by_service(self, resource_group): + response = self.client.api_version_set.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_wiki_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_api_wiki_operations.py index 05e241ed09ba..0e71c8f6a05e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,12 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_wiki_get_entity_tag(self, resource_group): - response = self.client.api_wiki.get_entity_tag( + def test_api_wiki_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-05-01", ) # please add some check logic here by yourself @@ -33,12 +32,11 @@ def test_api_wiki_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_api_wiki_get(self, resource_group): - response = self.client.api_wiki.get( + def test_api_wiki_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-05-01", ) # please add some check logic here by yourself @@ -51,8 +49,20 @@ def test_api_wiki_create_or_update(self, resource_group): 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-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"documents": [{"documentationId": "str"}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -65,9 +75,9 @@ def test_api_wiki_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - if_match="str", - parameters={"documents": [{"documentationId": "str"}]}, - api_version="2024-05-01", + parameters={"properties": {"documents": [{"documentationId": "str"}]}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -80,8 +90,8 @@ def test_api_wiki_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # 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 index 88a8e0acfecf..2c08059f4209 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,12 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_wiki_get_entity_tag(self, resource_group): - response = await self.client.api_wiki.get_entity_tag( + async def test_api_wiki_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-05-01", ) # please add some check logic here by yourself @@ -34,12 +33,11 @@ async def test_api_wiki_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_api_wiki_get(self, resource_group): - response = await self.client.api_wiki.get( + async def test_api_wiki_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-05-01", ) # please add some check logic here by yourself @@ -52,8 +50,20 @@ async def test_api_wiki_create_or_update(self, resource_group): 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-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"documents": [{"documentationId": "str"}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -66,9 +76,9 @@ async def test_api_wiki_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - if_match="str", - parameters={"documents": [{"documentationId": "str"}]}, - api_version="2024-05-01", + parameters={"properties": {"documents": [{"documentationId": "str"}]}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -81,8 +91,8 @@ async def test_api_wiki_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # 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 index abad6f100ddc..def785c47719 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_api_wikis_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-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 index a28454b2d1b9..ecbb172b1f1e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_api_wikis_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-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 index 505643c9f8bf..129141571ae8 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -39,7 +39,6 @@ async def test_begin_perform_connectivity_check_async(self, resource_group): } }, }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result 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 index b82eec07af03..fa3fad7ae299 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,20 +18,6 @@ class TestApiManagementAuthorizationAccessPolicyOperations(AzureMgmtRecordedTest def setup_method(self, method): self.client = self.create_mgmt_client(ApiManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_authorization_access_policy_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_authorization_access_policy_get(self, resource_group): @@ -41,7 +27,6 @@ def test_authorization_access_policy_get(self, resource_group): authorization_provider_id="str", authorization_id="str", authorization_access_policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -57,14 +42,19 @@ def test_authorization_access_policy_create_or_update(self, resource_group): authorization_id="str", authorization_access_policy_id="str", parameters={ - "appIds": ["str"], "id": "str", "name": "str", - "objectId": "str", - "tenantId": "str", + "properties": {"appIds": ["str"], "objectId": "str", "tenantId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -79,9 +69,22 @@ def test_authorization_access_policy_delete(self, resource_group): authorization_provider_id="str", authorization_id="str", authorization_access_policy_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_authorization_access_policy_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", + ) + 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_authorization_access_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_access_policy_operations_async.py index c885ad376933..5d8d742dc3d9 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,20 +19,6 @@ class TestApiManagementAuthorizationAccessPolicyOperationsAsync(AzureMgmtRecorde 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_authorization_access_policy_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-05-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_authorization_access_policy_get(self, resource_group): @@ -42,7 +28,6 @@ async def test_authorization_access_policy_get(self, resource_group): authorization_provider_id="str", authorization_id="str", authorization_access_policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -58,14 +43,19 @@ async def test_authorization_access_policy_create_or_update(self, resource_group authorization_id="str", authorization_access_policy_id="str", parameters={ - "appIds": ["str"], "id": "str", "name": "str", - "objectId": "str", - "tenantId": "str", + "properties": {"appIds": ["str"], "objectId": "str", "tenantId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -80,9 +70,22 @@ async def test_authorization_access_policy_delete(self, resource_group): authorization_provider_id="str", authorization_id="str", authorization_access_policy_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_authorization_access_policy_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", + ) + 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_authorization_login_links_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_authorization_login_links_operations.py index 4422ddad8a4c..a4bd8315ddf0 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ def test_authorization_login_links_post(self, resource_group): authorization_provider_id="str", authorization_id="str", parameters={"postLoginRedirectUrl": "str"}, - api_version="2024-05-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 index c8a16647634e..154e82007e66 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,7 +28,6 @@ async def test_authorization_login_links_post(self, resource_group): authorization_provider_id="str", authorization_id="str", parameters={"postLoginRedirectUrl": "str"}, - api_version="2024-05-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 index 0e7b08fcd8b4..805f7f01dac7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,19 +18,6 @@ class TestApiManagementAuthorizationOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ApiManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_authorization_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_authorization_get(self, resource_group): @@ -39,7 +26,6 @@ def test_authorization_get(self, resource_group): service_name="str", authorization_provider_id="str", authorization_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -54,16 +40,25 @@ def test_authorization_create_or_update(self, resource_group): 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", + "properties": { + "authorizationType": "str", + "error": {"code": "str", "message": "str"}, + "oauth2grantType": "str", + "parameters": {"str": "str"}, + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -77,13 +72,25 @@ def test_authorization_delete(self, resource_group): service_name="str", authorization_provider_id="str", authorization_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_authorization_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", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_authorization_confirm_consent_code(self, resource_group): @@ -93,7 +100,6 @@ def test_authorization_confirm_consent_code(self, resource_group): authorization_provider_id="str", authorization_id="str", parameters={"consentCode": "str"}, - api_version="2024-05-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 index 152f105e8183..6bfa725ac90a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,19 +19,6 @@ 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_authorization_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-05-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_authorization_get(self, resource_group): @@ -40,7 +27,6 @@ async def test_authorization_get(self, resource_group): service_name="str", authorization_provider_id="str", authorization_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -55,16 +41,25 @@ async def test_authorization_create_or_update(self, resource_group): 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", + "properties": { + "authorizationType": "str", + "error": {"code": "str", "message": "str"}, + "oauth2grantType": "str", + "parameters": {"str": "str"}, + "status": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -78,13 +73,25 @@ async def test_authorization_delete(self, resource_group): service_name="str", authorization_provider_id="str", authorization_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_authorization_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", + ) + 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_authorization_confirm_consent_code(self, resource_group): @@ -94,7 +101,6 @@ async def test_authorization_confirm_consent_code(self, resource_group): authorization_provider_id="str", authorization_id="str", parameters={"consentCode": "str"}, - api_version="2024-05-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 index bffd95aeaef3..9d24ad0d9ea9 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestApiManagementAuthorizationProviderOperations(AzureMgmtRecordedTestCase def setup_method(self, method): self.client = self.create_mgmt_client(ApiManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_authorization_provider_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_authorization_provider_get(self, resource_group): @@ -37,7 +25,6 @@ def test_authorization_provider_get(self, resource_group): resource_group_name=resource_group.name, service_name="str", authorization_provider_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -51,17 +38,31 @@ def test_authorization_provider_create_or_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "identityProvider": "str", + "oauth2": { + "grantTypes": {"authorizationCode": {"str": "str"}, "clientCredentials": {"str": "str"}}, + "keyVault": { + "lastStatus": {"code": "str", "message": "str", "timeStampUtc": "2020-02-20 00:00:00"}, + "secretIdentifier": "str", + "updated": "2020-02-20 00:00:00", + }, + "redirectUrl": "str", + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -74,8 +75,31 @@ def test_authorization_provider_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", authorization_provider_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_authorization_provider_list_by_service(self, resource_group): + response = self.client.authorization_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_authorization_provider_refresh_secret(self, resource_group): + response = self.client.authorization_provider.refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", ) # 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 index 791020a0ce9b..ec017f350074 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestApiManagementAuthorizationProviderOperationsAsync(AzureMgmtRecordedTes 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_authorization_provider_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-05-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_authorization_provider_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_authorization_provider_get(self, resource_group): resource_group_name=resource_group.name, service_name="str", authorization_provider_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -52,17 +39,31 @@ async def test_authorization_provider_create_or_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "identityProvider": "str", + "oauth2": { + "grantTypes": {"authorizationCode": {"str": "str"}, "clientCredentials": {"str": "str"}}, + "keyVault": { + "lastStatus": {"code": "str", "message": "str", "timeStampUtc": "2020-02-20 00:00:00"}, + "secretIdentifier": "str", + "updated": "2020-02-20 00:00:00", + }, + "redirectUrl": "str", + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -75,8 +76,31 @@ async def test_authorization_provider_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", authorization_provider_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_authorization_provider_list_by_service(self, resource_group): + response = self.client.authorization_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_authorization_provider_refresh_secret(self, resource_group): + response = await self.client.authorization_provider.refresh_secret( + resource_group_name=resource_group.name, + service_name="str", + authorization_provider_id="str", ) # 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 index 4d75af7a55f6..083c1d6fbc19 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_authorization_server_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_authorization_server_get_entity_tag(self, resource_group): - response = self.client.authorization_server.get_entity_tag( + def test_authorization_server_get(self, resource_group): + response = self.client.authorization_server.get( resource_group_name=resource_group.name, service_name="str", authsid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_authorization_server_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_authorization_server_get(self, resource_group): - response = self.client.authorization_server.get( + def test_authorization_server_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-05-01", ) # please add some check logic here by yourself @@ -64,29 +50,38 @@ def test_authorization_server_create_or_update(self, resource_group): 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", + "properties": { + "authorizationEndpoint": "str", + "clientId": "str", + "clientRegistrationEndpoint": "str", + "displayName": "str", + "grantTypes": ["str"], + "authorizationMethods": ["str"], + "bearerTokenSendingMethods": ["str"], + "clientAuthenticationMethod": ["str"], + "clientSecret": "str", + "defaultScope": "str", + "description": "str", + "resourceOwnerPassword": "str", + "resourceOwnerUsername": "str", + "supportState": bool, + "tokenBodyParameters": [{"name": "str", "value": "str"}], + "tokenEndpoint": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "useInApiDocumentation": bool, - "useInTestConsole": bool, }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -99,31 +94,41 @@ def test_authorization_server_update(self, resource_group): 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", + "properties": { + "authorizationEndpoint": "str", + "authorizationMethods": ["str"], + "bearerTokenSendingMethods": ["str"], + "clientAuthenticationMethod": ["str"], + "clientId": "str", + "clientRegistrationEndpoint": "str", + "clientSecret": "str", + "defaultScope": "str", + "description": "str", + "displayName": "str", + "grantTypes": ["str"], + "resourceOwnerPassword": "str", + "resourceOwnerUsername": "str", + "supportState": bool, + "tokenBodyParameters": [{"name": "str", "value": "str"}], + "tokenEndpoint": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "useInApiDocumentation": bool, - "useInTestConsole": bool, }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -136,13 +141,24 @@ def test_authorization_server_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", authsid="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_authorization_server_list_by_service(self, resource_group): + response = self.client.authorization_server.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_authorization_server_list_secrets(self, resource_group): @@ -150,7 +166,6 @@ def test_authorization_server_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", authsid="str", - api_version="2024-05-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 index 04fe00c4bf41..f894243a6279 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_authorization_server_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-05-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_authorization_server_get_entity_tag(self, resource_group): - response = await self.client.authorization_server.get_entity_tag( + async def test_authorization_server_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_authorization_server_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_authorization_server_get(self, resource_group): - response = await self.client.authorization_server.get( + async def test_authorization_server_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-05-01", ) # please add some check logic here by yourself @@ -65,29 +51,38 @@ async def test_authorization_server_create_or_update(self, resource_group): 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", + "properties": { + "authorizationEndpoint": "str", + "clientId": "str", + "clientRegistrationEndpoint": "str", + "displayName": "str", + "grantTypes": ["str"], + "authorizationMethods": ["str"], + "bearerTokenSendingMethods": ["str"], + "clientAuthenticationMethod": ["str"], + "clientSecret": "str", + "defaultScope": "str", + "description": "str", + "resourceOwnerPassword": "str", + "resourceOwnerUsername": "str", + "supportState": bool, + "tokenBodyParameters": [{"name": "str", "value": "str"}], + "tokenEndpoint": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "useInApiDocumentation": bool, - "useInTestConsole": bool, }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -100,31 +95,41 @@ async def test_authorization_server_update(self, resource_group): 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", + "properties": { + "authorizationEndpoint": "str", + "authorizationMethods": ["str"], + "bearerTokenSendingMethods": ["str"], + "clientAuthenticationMethod": ["str"], + "clientId": "str", + "clientRegistrationEndpoint": "str", + "clientSecret": "str", + "defaultScope": "str", + "description": "str", + "displayName": "str", + "grantTypes": ["str"], + "resourceOwnerPassword": "str", + "resourceOwnerUsername": "str", + "supportState": bool, + "tokenBodyParameters": [{"name": "str", "value": "str"}], + "tokenEndpoint": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "useInApiDocumentation": bool, - "useInTestConsole": bool, }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -137,13 +142,24 @@ async def test_authorization_server_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", authsid="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_authorization_server_list_by_service(self, resource_group): + response = self.client.authorization_server.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_authorization_server_list_secrets(self, resource_group): @@ -151,7 +167,6 @@ async def test_authorization_server_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", authsid="str", - api_version="2024-05-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 index 36a5258d4163..b3dc7c505563 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_backend_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_backend_get_entity_tag(self, resource_group): - response = self.client.backend.get_entity_tag( + def test_backend_get(self, resource_group): + response = self.client.backend.get( resource_group_name=resource_group.name, service_name="str", backend_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_backend_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_backend_get(self, resource_group): - response = self.client.backend.get( + def test_backend_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-05-01", ) # please add some check logic here by yourself @@ -64,52 +50,73 @@ def test_backend_create_or_update(self, resource_group): 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, + "azureRegion": "str", + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "failureResponse": {"statusCode": 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": { + "failureResponse": {"statusCode": 0}, + "services": [{"id": "str", "preferredCarbonEmission": "str", "priority": 0, "weight": 0}], + "sessionAffinity": {"sessionId": {"name": "str", "source": "str"}}, + }, + "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": { "serverCertificateThumbprints": ["str"], "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], - } + "validateCertificateChain": bool, + "validateCertificateName": bool, + }, + "type": "str", + "url": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -122,52 +129,65 @@ def test_backend_update(self, resource_group): 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, + "azureRegion": "str", + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "failureResponse": {"statusCode": 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": { + "failureResponse": {"statusCode": 0}, + "services": [{"id": "str", "preferredCarbonEmission": "str", "priority": 0, "weight": 0}], + "sessionAffinity": {"sessionId": {"name": "str", "source": "str"}}, + }, + "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": { "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", + "validateCertificateChain": bool, + "validateCertificateName": bool, + }, + "type": "str", + "url": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -180,13 +200,24 @@ def test_backend_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", backend_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_backend_list_by_service(self, resource_group): + response = self.client.backend.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_backend_reconnect(self, resource_group): @@ -194,7 +225,6 @@ def test_backend_reconnect(self, resource_group): resource_group_name=resource_group.name, service_name="str", backend_id="str", - api_version="2024-05-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 index 2dc9442159bd..70663739ec88 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_backend_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-05-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_backend_get_entity_tag(self, resource_group): - response = await self.client.backend.get_entity_tag( + async def test_backend_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_backend_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_backend_get(self, resource_group): - response = await self.client.backend.get( + async def test_backend_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-05-01", ) # please add some check logic here by yourself @@ -65,52 +51,73 @@ async def test_backend_create_or_update(self, resource_group): 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, + "azureRegion": "str", + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "failureResponse": {"statusCode": 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": { + "failureResponse": {"statusCode": 0}, + "services": [{"id": "str", "preferredCarbonEmission": "str", "priority": 0, "weight": 0}], + "sessionAffinity": {"sessionId": {"name": "str", "source": "str"}}, + }, + "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": { "serverCertificateThumbprints": ["str"], "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], - } + "validateCertificateChain": bool, + "validateCertificateName": bool, + }, + "type": "str", + "url": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -123,52 +130,65 @@ async def test_backend_update(self, resource_group): 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, + "azureRegion": "str", + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "failureResponse": {"statusCode": 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": { + "failureResponse": {"statusCode": 0}, + "services": [{"id": "str", "preferredCarbonEmission": "str", "priority": 0, "weight": 0}], + "sessionAffinity": {"sessionId": {"name": "str", "source": "str"}}, + }, + "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": { "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", + "validateCertificateChain": bool, + "validateCertificateName": bool, + }, + "type": "str", + "url": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -181,13 +201,24 @@ async def test_backend_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", backend_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_backend_list_by_service(self, resource_group): + response = self.client.backend.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_backend_reconnect(self, resource_group): @@ -195,7 +226,6 @@ async def test_backend_reconnect(self, resource_group): resource_group_name=resource_group.name, service_name="str", backend_id="str", - api_version="2024-05-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 index b89a0542714c..61ec84586afb 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_cache_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_cache_get_entity_tag(self, resource_group): - response = self.client.cache.get_entity_tag( + def test_cache_get(self, resource_group): + response = self.client.cache.get( resource_group_name=resource_group.name, service_name="str", cache_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_cache_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_cache_get(self, resource_group): - response = self.client.cache.get( + def test_cache_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-05-01", ) # please add some check logic here by yourself @@ -64,15 +50,24 @@ def test_cache_create_or_update(self, resource_group): service_name="str", cache_id="str", parameters={ - "connectionString": "str", - "description": "str", "id": "str", "name": "str", - "resourceId": "str", + "properties": { + "connectionString": "str", + "useFromLocation": "str", + "description": "str", + "resourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "useFromLocation": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -85,9 +80,16 @@ def test_cache_update(self, resource_group): 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-05-01", + parameters={ + "properties": { + "connectionString": "str", + "description": "str", + "resourceId": "str", + "useFromLocation": "str", + } + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -100,9 +102,20 @@ def test_cache_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", cache_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_cache_list_by_service(self, resource_group): + response = self.client.cache.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_cache_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_cache_operations_async.py index 66922aa1090c..5c0dd5f3883a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_cache_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-05-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_cache_get_entity_tag(self, resource_group): - response = await self.client.cache.get_entity_tag( + async def test_cache_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_cache_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_cache_get(self, resource_group): - response = await self.client.cache.get( + async def test_cache_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-05-01", ) # please add some check logic here by yourself @@ -65,15 +51,24 @@ async def test_cache_create_or_update(self, resource_group): service_name="str", cache_id="str", parameters={ - "connectionString": "str", - "description": "str", "id": "str", "name": "str", - "resourceId": "str", + "properties": { + "connectionString": "str", + "useFromLocation": "str", + "description": "str", + "resourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "useFromLocation": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -86,9 +81,16 @@ async def test_cache_update(self, resource_group): 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-05-01", + parameters={ + "properties": { + "connectionString": "str", + "description": "str", + "resourceId": "str", + "useFromLocation": "str", + } + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -101,9 +103,20 @@ async def test_cache_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", cache_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_cache_list_by_service(self, resource_group): + response = self.client.cache.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_certificate_operations.py index 18199986b08e..6ca0dddb4f25 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_certificate_list_by_service(self, resource_group): - response = self.client.certificate.list_by_service( + def test_certificate_get(self, resource_group): + response = self.client.certificate.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + certificate_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -37,7 +37,6 @@ def test_certificate_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", certificate_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +44,18 @@ def test_certificate_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_certificate_get(self, resource_group): - response = self.client.certificate.get( + def test_certificate_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", - api_version="2024-05-01", + parameters={ + "properties": { + "data": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "password": "str", + } + }, ) # please add some check logic here by yourself @@ -58,17 +63,13 @@ def test_certificate_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_certificate_create_or_update(self, resource_group): - response = self.client.certificate.create_or_update( + def test_certificate_delete(self, resource_group): + response = self.client.certificate.delete( 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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -76,15 +77,12 @@ def test_certificate_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_certificate_delete(self, resource_group): - response = self.client.certificate.delete( + def test_certificate_list_by_service(self, resource_group): + response = self.client.certificate.list_by_service( resource_group_name=resource_group.name, service_name="str", - certificate_id="str", - if_match="str", - api_version="2024-05-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -95,7 +93,6 @@ def test_certificate_refresh_secret(self, resource_group): resource_group_name=resource_group.name, service_name="str", certificate_id="str", - api_version="2024-05-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 index 5463a2036327..b62d93e24284 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_certificate_list_by_service(self, resource_group): - response = self.client.certificate.list_by_service( + async def test_certificate_get(self, resource_group): + response = await self.client.certificate.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + certificate_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -38,7 +38,6 @@ async def test_certificate_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", certificate_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,12 +45,18 @@ async def test_certificate_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_certificate_get(self, resource_group): - response = await self.client.certificate.get( + async def test_certificate_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", - api_version="2024-05-01", + parameters={ + "properties": { + "data": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "password": "str", + } + }, ) # please add some check logic here by yourself @@ -59,17 +64,13 @@ async def test_certificate_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_certificate_create_or_update(self, resource_group): - response = await self.client.certificate.create_or_update( + async def test_certificate_delete(self, resource_group): + response = await self.client.certificate.delete( 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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -77,15 +78,12 @@ async def test_certificate_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_certificate_delete(self, resource_group): - response = await self.client.certificate.delete( + async def test_certificate_list_by_service(self, resource_group): + response = self.client.certificate.list_by_service( resource_group_name=resource_group.name, service_name="str", - certificate_id="str", - if_match="str", - api_version="2024-05-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -96,7 +94,6 @@ async def test_certificate_refresh_secret(self, resource_group): resource_group_name=resource_group.name, service_name="str", certificate_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_operations.py new file mode 100644 index 000000000000..481bc7e564d8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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 TestApiManagementClientApplicationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_get(self, resource_group): + response = self.client.client_application.get( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_get_entity_tag(self, resource_group): + response = self.client.client_application.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_create_or_update(self, resource_group): + response = self.client.client_application.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "displayName": "str", + "ownerId": "str", + "description": "str", + "entraApplicationId": "str", + "entraTenantId": "str", + "state": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_delete(self, resource_group): + response = self.client.client_application.delete( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_list_by_service(self, resource_group): + response = self.client.client_application.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_list_secrets(self, resource_group): + response = self.client.client_application.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_operations_async.py new file mode 100644 index 000000000000..f9aabfd99abe --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_operations_async.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) Python 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 TestApiManagementClientApplicationOperationsAsync(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_client_application_get(self, resource_group): + response = await self.client.client_application.get( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_client_application_get_entity_tag(self, resource_group): + response = await self.client.client_application.get_entity_tag( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_client_application_create_or_update(self, resource_group): + response = await self.client.client_application.create_or_update( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "displayName": "str", + "ownerId": "str", + "description": "str", + "entraApplicationId": "str", + "entraTenantId": "str", + "state": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_client_application_delete(self, resource_group): + response = await self.client.client_application.delete( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_client_application_list_by_service(self, resource_group): + response = self.client.client_application.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_client_application_list_secrets(self, resource_group): + response = await self.client.client_application.list_secrets( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_product_link_operations.py new file mode 100644 index 000000000000..9dc13fcb9cf2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_product_link_operations.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python 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 TestApiManagementClientApplicationProductLinkOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(ApiManagementClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_product_link_get(self, resource_group): + response = self.client.client_application_product_link.get( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + client_application_product_link_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_product_link_create(self, resource_group): + response = self.client.client_application_product_link.create( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + client_application_product_link_id="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"productId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_product_link_delete(self, resource_group): + response = self.client.client_application_product_link.delete( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + client_application_product_link_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_client_application_product_link_list_by_client_applications(self, resource_group): + response = self.client.client_application_product_link.list_by_client_applications( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + 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_client_application_product_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_product_link_operations_async.py new file mode 100644 index 000000000000..162ae30d1d92 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_client_application_product_link_operations_async.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) Python 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 TestApiManagementClientApplicationProductLinkOperationsAsync(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_client_application_product_link_get(self, resource_group): + response = await self.client.client_application_product_link.get( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + client_application_product_link_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_client_application_product_link_create(self, resource_group): + response = await self.client.client_application_product_link.create( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + client_application_product_link_id="str", + parameters={ + "id": "str", + "name": "str", + "properties": {"productId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_client_application_product_link_delete(self, resource_group): + response = await self.client.client_application_product_link.delete( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + client_application_product_link_id="str", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_client_application_product_link_list_by_client_applications(self, resource_group): + response = self.client.client_application_product_link.list_by_client_applications( + resource_group_name=resource_group.name, + service_name="str", + client_application_id="str", + ) + 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_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations.py index 5c9e97c02def..1dd71e7b2d9a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_content_item_list_by_service(self, resource_group): - response = self.client.content_item.list_by_service( + def test_content_item_get(self, resource_group): + response = self.client.content_item.get( resource_group_name=resource_group.name, service_name="str", content_type_id="str", - api_version="2024-05-01", + content_item_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -39,7 +39,6 @@ def test_content_item_get_entity_tag(self, resource_group): service_name="str", content_type_id="str", content_item_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,26 @@ def test_content_item_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_content_item_get(self, resource_group): - response = self.client.content_item.get( + def test_content_item_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"str": {}}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -61,14 +73,14 @@ def test_content_item_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_content_item_create_or_update(self, resource_group): - response = self.client.content_item.create_or_update( + def test_content_item_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", - parameters={"id": "str", "name": "str", "properties": {"str": {}}, "type": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -76,15 +88,12 @@ def test_content_item_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_content_item_delete(self, resource_group): - response = self.client.content_item.delete( + def test_content_item_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", - content_item_id="str", - if_match="str", - api_version="2024-05-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_content_item_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_item_operations_async.py index cf0aeb06d22f..ccb14bca8b84 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_content_item_list_by_service(self, resource_group): - response = self.client.content_item.list_by_service( + async def test_content_item_get(self, resource_group): + response = await self.client.content_item.get( resource_group_name=resource_group.name, service_name="str", content_type_id="str", - api_version="2024-05-01", + content_item_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +40,6 @@ async def test_content_item_get_entity_tag(self, resource_group): service_name="str", content_type_id="str", content_item_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,26 @@ async def test_content_item_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_content_item_get(self, resource_group): - response = await self.client.content_item.get( + async def test_content_item_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"str": {}}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -62,14 +74,14 @@ async def test_content_item_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_content_item_create_or_update(self, resource_group): - response = await self.client.content_item.create_or_update( + async def test_content_item_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", - parameters={"id": "str", "name": "str", "properties": {"str": {}}, "type": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -77,15 +89,12 @@ async def test_content_item_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_content_item_delete(self, resource_group): - response = await self.client.content_item.delete( + async def test_content_item_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", - content_item_id="str", - if_match="str", - api_version="2024-05-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_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations.py index bcdf5d36ab0d..4369860b3c8e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestApiManagementContentTypeOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ApiManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_content_type_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_content_type_get(self, resource_group): @@ -37,7 +25,6 @@ def test_content_type_get(self, resource_group): resource_group_name=resource_group.name, service_name="str", content_type_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -51,14 +38,19 @@ def test_content_type_create_or_update(self, resource_group): service_name="str", content_type_id="str", parameters={ - "description": "str", "id": "str", "name": "str", - "schema": {}, + "properties": {"description": "str", "id": "str", "name": "str", "schema": {}, "version": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "version": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -71,9 +63,20 @@ def test_content_type_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", content_type_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_content_type_list_by_service(self, resource_group): + response = self.client.content_type.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_content_type_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_content_type_operations_async.py index 229079f4b923..c91aa61eb42e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ 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_content_type_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-05-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_content_type_get(self, resource_group): @@ -38,7 +26,6 @@ async def test_content_type_get(self, resource_group): resource_group_name=resource_group.name, service_name="str", content_type_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -52,14 +39,19 @@ async def test_content_type_create_or_update(self, resource_group): service_name="str", content_type_id="str", parameters={ - "description": "str", "id": "str", "name": "str", - "schema": {}, + "properties": {"description": "str", "id": "str", "name": "str", "schema": {}, "version": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "version": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -72,9 +64,20 @@ async def test_content_type_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", content_type_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_content_type_list_by_service(self, resource_group): + response = self.client.content_type.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_delegation_settings_operations.py index 6a2795b4fafc..c85eb5f55874 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,11 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_delegation_settings_get_entity_tag(self, resource_group): - response = self.client.delegation_settings.get_entity_tag( + def test_delegation_settings_get(self, resource_group): + response = self.client.delegation_settings.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -32,11 +31,10 @@ def test_delegation_settings_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_delegation_settings_get(self, resource_group): - response = self.client.delegation_settings.get( + def test_delegation_settings_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-05-01", ) # please add some check logic here by yourself @@ -44,21 +42,29 @@ def test_delegation_settings_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_delegation_settings_update(self, resource_group): - response = self.client.delegation_settings.update( + def test_delegation_settings_create_or_update(self, resource_group): + response = self.client.delegation_settings.create_or_update( resource_group_name=resource_group.name, service_name="str", - if_match="str", parameters={ "id": "str", "name": "str", - "subscriptions": {"enabled": bool}, + "properties": { + "subscriptions": {"enabled": bool}, + "url": "str", + "userRegistration": {"enabled": bool}, + "validationKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "url": "str", - "userRegistration": {"enabled": bool}, - "validationKey": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -66,20 +72,31 @@ def test_delegation_settings_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_delegation_settings_create_or_update(self, resource_group): - response = self.client.delegation_settings.create_or_update( + def test_delegation_settings_update(self, resource_group): + response = self.client.delegation_settings.update( resource_group_name=resource_group.name, service_name="str", parameters={ "id": "str", "name": "str", - "subscriptions": {"enabled": bool}, + "properties": { + "subscriptions": {"enabled": bool}, + "url": "str", + "userRegistration": {"enabled": bool}, + "validationKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "url": "str", - "userRegistration": {"enabled": bool}, - "validationKey": "str", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -91,7 +108,6 @@ def test_delegation_settings_list_secrets(self, resource_group): response = self.client.delegation_settings.list_secrets( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-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 index 3bb2990d5fea..b699a146c2d1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,11 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_delegation_settings_get_entity_tag(self, resource_group): - response = await self.client.delegation_settings.get_entity_tag( + async def test_delegation_settings_get(self, resource_group): + response = await self.client.delegation_settings.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -33,11 +32,10 @@ async def test_delegation_settings_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_delegation_settings_get(self, resource_group): - response = await self.client.delegation_settings.get( + async def test_delegation_settings_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-05-01", ) # please add some check logic here by yourself @@ -45,21 +43,29 @@ async def test_delegation_settings_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_delegation_settings_update(self, resource_group): - response = await self.client.delegation_settings.update( + async def test_delegation_settings_create_or_update(self, resource_group): + response = await self.client.delegation_settings.create_or_update( resource_group_name=resource_group.name, service_name="str", - if_match="str", parameters={ "id": "str", "name": "str", - "subscriptions": {"enabled": bool}, + "properties": { + "subscriptions": {"enabled": bool}, + "url": "str", + "userRegistration": {"enabled": bool}, + "validationKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "url": "str", - "userRegistration": {"enabled": bool}, - "validationKey": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -67,20 +73,31 @@ async def test_delegation_settings_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_delegation_settings_create_or_update(self, resource_group): - response = await self.client.delegation_settings.create_or_update( + async def test_delegation_settings_update(self, resource_group): + response = await self.client.delegation_settings.update( resource_group_name=resource_group.name, service_name="str", parameters={ "id": "str", "name": "str", - "subscriptions": {"enabled": bool}, + "properties": { + "subscriptions": {"enabled": bool}, + "url": "str", + "userRegistration": {"enabled": bool}, + "validationKey": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "url": "str", - "userRegistration": {"enabled": bool}, - "validationKey": "str", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -92,7 +109,6 @@ async def test_delegation_settings_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-05-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 index 4dc386e3787c..0ae377421c59 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,23 +18,12 @@ class TestApiManagementDeletedServicesOperations(AzureMgmtRecordedTestCase): def setup_method(self, method): self.client = self.create_mgmt_client(ApiManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_deleted_services_list_by_subscription(self, resource_group): - response = self.client.deleted_services.list_by_subscription( - api_version="2024-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_deleted_services_get_by_name(self, resource_group): response = self.client.deleted_services.get_by_name( service_name="str", location="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,8 +35,15 @@ def test_deleted_services_begin_purge(self, resource_group): response = self.client.deleted_services.begin_purge( service_name="str", location="str", - api_version="2024-05-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_deleted_services_list_by_subscription(self, resource_group): + response = self.client.deleted_services.list_by_subscription() + 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_deleted_services_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_deleted_services_operations_async.py index 2a033fb0012c..cd06364fcd55 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,23 +19,12 @@ 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_deleted_services_list_by_subscription(self, resource_group): - response = self.client.deleted_services.list_by_subscription( - api_version="2024-05-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_deleted_services_get_by_name(self, resource_group): response = await self.client.deleted_services.get_by_name( service_name="str", location="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,9 +37,16 @@ async def test_deleted_services_begin_purge(self, resource_group): await self.client.deleted_services.begin_purge( service_name="str", location="str", - api_version="2024-05-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_deleted_services_list_by_subscription(self, resource_group): + response = self.client.deleted_services.list_by_subscription() + 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_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations.py index ebf7d1cbddc2..91ca7c3b44a6 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_diagnostic_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_diagnostic_get_entity_tag(self, resource_group): - response = self.client.diagnostic.get_entity_tag( + def test_diagnostic_get(self, resource_group): + response = self.client.diagnostic.get( resource_group_name=resource_group.name, service_name="str", diagnostic_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_diagnostic_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_diagnostic_get(self, resource_group): - response = self.client.diagnostic.get( + def test_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -64,55 +50,69 @@ def test_diagnostic_create_or_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -125,57 +125,72 @@ def test_diagnostic_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -188,9 +203,20 @@ def test_diagnostic_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", diagnostic_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_diagnostic_list_by_service(self, resource_group): + response = self.client.diagnostic.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_diagnostic_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_diagnostic_operations_async.py index fa74106245b8..c1a8a8eeeae4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_diagnostic_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-05-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_diagnostic_get_entity_tag(self, resource_group): - response = await self.client.diagnostic.get_entity_tag( + async def test_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_diagnostic_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_diagnostic_get(self, resource_group): - response = await self.client.diagnostic.get( + async def test_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -65,55 +51,69 @@ async def test_diagnostic_create_or_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -126,57 +126,72 @@ async def test_diagnostic_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -189,9 +204,20 @@ async def test_diagnostic_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", diagnostic_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_diagnostic_list_by_service(self, resource_group): + response = self.client.diagnostic.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_documentation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations.py index e325fa776830..9ef58f62d524 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_documentation_list_by_service(self, resource_group): - response = self.client.documentation.list_by_service( + def test_documentation_get(self, resource_group): + response = self.client.documentation.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + documentation_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -37,7 +37,6 @@ def test_documentation_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", documentation_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +44,25 @@ def test_documentation_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_documentation_get(self, resource_group): - response = self.client.documentation.get( + def test_documentation_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"content": "str", "title": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -58,13 +70,14 @@ def test_documentation_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_documentation_create_or_update(self, resource_group): - response = self.client.documentation.create_or_update( + def test_documentation_update(self, resource_group): + response = self.client.documentation.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-05-01", + parameters={"properties": {"content": "str", "title": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -72,14 +85,13 @@ def test_documentation_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_documentation_update(self, resource_group): - response = self.client.documentation.update( + def test_documentation_delete(self, resource_group): + response = self.client.documentation.delete( resource_group_name=resource_group.name, service_name="str", documentation_id="str", - if_match="str", - parameters={"content": "str", "title": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -87,14 +99,11 @@ def test_documentation_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_documentation_delete(self, resource_group): - response = self.client.documentation.delete( + def test_documentation_list_by_service(self, resource_group): + response = self.client.documentation.list_by_service( resource_group_name=resource_group.name, service_name="str", - documentation_id="str", - if_match="str", - api_version="2024-05-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_documentation_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_documentation_operations_async.py index 98e4dfee4237..b75518062063 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_documentation_list_by_service(self, resource_group): - response = self.client.documentation.list_by_service( + async def test_documentation_get(self, resource_group): + response = await self.client.documentation.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + documentation_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -38,7 +38,6 @@ async def test_documentation_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", documentation_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,12 +45,25 @@ async def test_documentation_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_documentation_get(self, resource_group): - response = await self.client.documentation.get( + async def test_documentation_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"content": "str", "title": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -59,13 +71,14 @@ async def test_documentation_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_documentation_create_or_update(self, resource_group): - response = await self.client.documentation.create_or_update( + async def test_documentation_update(self, resource_group): + response = await self.client.documentation.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-05-01", + parameters={"properties": {"content": "str", "title": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -73,14 +86,13 @@ async def test_documentation_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_documentation_update(self, resource_group): - response = await self.client.documentation.update( + async def test_documentation_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", - parameters={"content": "str", "title": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -88,14 +100,11 @@ async def test_documentation_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_documentation_delete(self, resource_group): - response = await self.client.documentation.delete( + async def test_documentation_list_by_service(self, resource_group): + response = self.client.documentation.list_by_service( resource_group_name=resource_group.name, service_name="str", - documentation_id="str", - if_match="str", - api_version="2024-05-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_email_template_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations.py index 3b156b37b864..2cb5a614ae5f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_email_template_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_email_template_get_entity_tag(self, resource_group): - response = self.client.email_template.get_entity_tag( + def test_email_template_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-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_email_template_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_email_template_get(self, resource_group): - response = self.client.email_template.get( + def test_email_template_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-05-01", ) # please add some check logic here by yourself @@ -64,13 +50,14 @@ def test_email_template_create_or_update(self, resource_group): service_name="str", template_name="str", parameters={ - "body": "str", - "description": "str", - "parameters": [{"description": "str", "name": "str", "title": "str"}], - "subject": "str", - "title": "str", + "properties": { + "body": "str", + "description": "str", + "parameters": [{"description": "str", "name": "str", "title": "str"}], + "subject": "str", + "title": "str", + } }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -83,15 +70,17 @@ def test_email_template_update(self, resource_group): 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", + "properties": { + "body": "str", + "description": "str", + "parameters": [{"description": "str", "name": "str", "title": "str"}], + "subject": "str", + "title": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -104,9 +93,20 @@ def test_email_template_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", template_name="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_email_template_list_by_service(self, resource_group): + response = self.client.email_template.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_email_template_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_email_template_operations_async.py index 46925df8bb9d..51299ab46724 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_email_template_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-05-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_email_template_get_entity_tag(self, resource_group): - response = await self.client.email_template.get_entity_tag( + async def test_email_template_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_email_template_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_email_template_get(self, resource_group): - response = await self.client.email_template.get( + async def test_email_template_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-05-01", ) # please add some check logic here by yourself @@ -65,13 +51,14 @@ async def test_email_template_create_or_update(self, resource_group): service_name="str", template_name="str", parameters={ - "body": "str", - "description": "str", - "parameters": [{"description": "str", "name": "str", "title": "str"}], - "subject": "str", - "title": "str", + "properties": { + "body": "str", + "description": "str", + "parameters": [{"description": "str", "name": "str", "title": "str"}], + "subject": "str", + "title": "str", + } }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -84,15 +71,17 @@ async def test_email_template_update(self, resource_group): 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", + "properties": { + "body": "str", + "description": "str", + "parameters": [{"description": "str", "name": "str", "title": "str"}], + "subject": "str", + "title": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -105,9 +94,20 @@ async def test_email_template_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", template_name="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_email_template_list_by_service(self, resource_group): + response = self.client.email_template.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_gateway_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_api_operations.py index 3aadc95277f7..fc7044e7d150 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_gateway_api_list_by_service(self, resource_group): resource_group_name=resource_group.name, service_name="str", gateway_id="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -39,7 +38,6 @@ def test_gateway_api_get_entity_tag(self, resource_group): service_name="str", gateway_id="str", api_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -53,7 +51,6 @@ def test_gateway_api_create_or_update(self, resource_group): service_name="str", gateway_id="str", api_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -67,7 +64,6 @@ def test_gateway_api_delete(self, resource_group): service_name="str", gateway_id="str", api_id="str", - api_version="2024-05-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 index c4a4d4594e1a..5aa86c3703b6 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_gateway_api_list_by_service(self, resource_group): resource_group_name=resource_group.name, service_name="str", gateway_id="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -40,7 +39,6 @@ async def test_gateway_api_get_entity_tag(self, resource_group): service_name="str", gateway_id="str", api_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -54,7 +52,6 @@ async def test_gateway_api_create_or_update(self, resource_group): service_name="str", gateway_id="str", api_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -68,7 +65,6 @@ async def test_gateway_api_delete(self, resource_group): service_name="str", gateway_id="str", api_id="str", - api_version="2024-05-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 index 84f64b5562a9..b9082f3d8e55 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_gateway_certificate_authority_list_by_service(self, resource_group): - response = self.client.gateway_certificate_authority.list_by_service( + def test_gateway_certificate_authority_get(self, resource_group): + response = self.client.gateway_certificate_authority.get( resource_group_name=resource_group.name, service_name="str", gateway_id="str", - api_version="2024-05-01", + certificate_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -39,7 +39,6 @@ def test_gateway_certificate_authority_get_entity_tag(self, resource_group): service_name="str", gateway_id="str", certificate_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,26 @@ def test_gateway_certificate_authority_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_gateway_certificate_authority_get(self, resource_group): - response = self.client.gateway_certificate_authority.get( + def test_gateway_certificate_authority_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"isTrusted": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -61,14 +73,14 @@ def test_gateway_certificate_authority_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_gateway_certificate_authority_create_or_update(self, resource_group): - response = self.client.gateway_certificate_authority.create_or_update( + def test_gateway_certificate_authority_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", - parameters={"id": "str", "isTrusted": bool, "name": "str", "type": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -76,15 +88,12 @@ def test_gateway_certificate_authority_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_gateway_certificate_authority_delete(self, resource_group): - response = self.client.gateway_certificate_authority.delete( + def test_gateway_certificate_authority_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", - certificate_id="str", - if_match="str", - api_version="2024-05-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_gateway_certificate_authority_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_certificate_authority_operations_async.py index 449e4d11db10..e870a91c0fa0 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_gateway_certificate_authority_list_by_service(self, resource_group): - response = self.client.gateway_certificate_authority.list_by_service( + async def test_gateway_certificate_authority_get(self, resource_group): + response = await self.client.gateway_certificate_authority.get( resource_group_name=resource_group.name, service_name="str", gateway_id="str", - api_version="2024-05-01", + certificate_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +40,6 @@ async def test_gateway_certificate_authority_get_entity_tag(self, resource_group service_name="str", gateway_id="str", certificate_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,26 @@ async def test_gateway_certificate_authority_get_entity_tag(self, resource_group @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_gateway_certificate_authority_get(self, resource_group): - response = await self.client.gateway_certificate_authority.get( + async def test_gateway_certificate_authority_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"isTrusted": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -62,14 +74,14 @@ async def test_gateway_certificate_authority_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_gateway_certificate_authority_create_or_update(self, resource_group): - response = await self.client.gateway_certificate_authority.create_or_update( + async def test_gateway_certificate_authority_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", - parameters={"id": "str", "isTrusted": bool, "name": "str", "type": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -77,15 +89,12 @@ async def test_gateway_certificate_authority_create_or_update(self, resource_gro @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_gateway_certificate_authority_delete(self, resource_group): - response = await self.client.gateway_certificate_authority.delete( + async def test_gateway_certificate_authority_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", - certificate_id="str", - if_match="str", - api_version="2024-05-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_gateway_hostname_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations.py index 2e17274869df..9cefcd3eb640 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_gateway_hostname_configuration_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_gateway_hostname_configuration_get_entity_tag(self, resource_group): - response = self.client.gateway_hostname_configuration.get_entity_tag( + def test_gateway_hostname_configuration_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_gateway_hostname_configuration_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_gateway_hostname_configuration_get(self, resource_group): - response = self.client.gateway_hostname_configuration.get( + def test_gateway_hostname_configuration_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-05-01", ) # please add some check logic here by yourself @@ -68,17 +53,26 @@ def test_gateway_hostname_configuration_create_or_update(self, resource_group): gateway_id="str", hc_id="str", parameters={ - "certificateId": "str", - "hostname": "str", - "http2Enabled": bool, "id": "str", "name": "str", - "negotiateClientCertificate": bool, - "tls10Enabled": bool, - "tls11Enabled": bool, + "properties": { + "certificateId": "str", + "hostname": "str", + "http2Enabled": bool, + "negotiateClientCertificate": bool, + "tls10Enabled": bool, + "tls11Enabled": bool, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -92,9 +86,21 @@ def test_gateway_hostname_configuration_delete(self, resource_group): service_name="str", gateway_id="str", hc_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_gateway_hostname_configuration_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", + ) + 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_gateway_hostname_configuration_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_hostname_configuration_operations_async.py index 8f796225529a..c32c2802d2a4 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_gateway_hostname_configuration_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-05-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_gateway_hostname_configuration_get_entity_tag(self, resource_group): - response = await self.client.gateway_hostname_configuration.get_entity_tag( + async def test_gateway_hostname_configuration_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_gateway_hostname_configuration_get_entity_tag(self, resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_gateway_hostname_configuration_get(self, resource_group): - response = await self.client.gateway_hostname_configuration.get( + async def test_gateway_hostname_configuration_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-05-01", ) # please add some check logic here by yourself @@ -69,17 +54,26 @@ async def test_gateway_hostname_configuration_create_or_update(self, resource_gr gateway_id="str", hc_id="str", parameters={ - "certificateId": "str", - "hostname": "str", - "http2Enabled": bool, "id": "str", "name": "str", - "negotiateClientCertificate": bool, - "tls10Enabled": bool, - "tls11Enabled": bool, + "properties": { + "certificateId": "str", + "hostname": "str", + "http2Enabled": bool, + "negotiateClientCertificate": bool, + "tls10Enabled": bool, + "tls11Enabled": bool, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -93,9 +87,21 @@ async def test_gateway_hostname_configuration_delete(self, resource_group): service_name="str", gateway_id="str", hc_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_gateway_hostname_configuration_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", + ) + 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_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_gateway_operations.py index 26324833afe8..f180e409c9a0 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_gateway_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_gateway_get_entity_tag(self, resource_group): - response = self.client.gateway.get_entity_tag( + def test_gateway_get(self, resource_group): + response = self.client.gateway.get( resource_group_name=resource_group.name, service_name="str", gateway_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_gateway_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_gateway_get(self, resource_group): - response = self.client.gateway.get( + def test_gateway_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-05-01", ) # please add some check logic here by yourself @@ -64,13 +50,28 @@ def test_gateway_create_or_update(self, resource_group): service_name="str", gateway_id="str", parameters={ - "description": "str", "id": "str", - "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, "name": "str", + "properties": { + "description": "str", + "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -83,15 +84,31 @@ def test_gateway_update(self, resource_group): 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"}, + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, "name": "str", + "properties": { + "description": "str", + "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -104,13 +121,24 @@ def test_gateway_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", gateway_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_gateway_list_by_service(self, resource_group): + response = self.client.gateway.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_gateway_list_keys(self, resource_group): @@ -118,7 +146,6 @@ def test_gateway_list_keys(self, resource_group): resource_group_name=resource_group.name, service_name="str", gateway_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -132,7 +159,6 @@ def test_gateway_regenerate_key(self, resource_group): service_name="str", gateway_id="str", parameters={"keyType": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -146,7 +172,6 @@ def test_gateway_generate_token(self, resource_group): service_name="str", gateway_id="str", parameters={"expiry": "2020-02-20 00:00:00", "keyType": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -159,7 +184,6 @@ def test_gateway_invalidate_debug_credentials(self, resource_group): resource_group_name=resource_group.name, service_name="str", gateway_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -173,7 +197,6 @@ def test_gateway_list_debug_credentials(self, resource_group): service_name="str", gateway_id="str", parameters={"apiId": "str", "purposes": ["str"], "credentialsExpireAfter": "1 day, 0:00:00"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -187,7 +210,6 @@ def test_gateway_list_trace(self, resource_group): service_name="str", gateway_id="str", parameters={"traceId": "str"}, - api_version="2024-05-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 index 0f552105cf5d..d0e5a8ae4ff1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_gateway_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-05-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_gateway_get_entity_tag(self, resource_group): - response = await self.client.gateway.get_entity_tag( + async def test_gateway_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_gateway_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_gateway_get(self, resource_group): - response = await self.client.gateway.get( + async def test_gateway_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-05-01", ) # please add some check logic here by yourself @@ -65,13 +51,28 @@ async def test_gateway_create_or_update(self, resource_group): service_name="str", gateway_id="str", parameters={ - "description": "str", "id": "str", - "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, "name": "str", + "properties": { + "description": "str", + "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -84,15 +85,31 @@ async def test_gateway_update(self, resource_group): 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"}, + "identity": { + "type": "str", + "principalId": "str", + "tenantId": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, "name": "str", + "properties": { + "description": "str", + "locationData": {"name": "str", "city": "str", "countryOrRegion": "str", "district": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -105,13 +122,24 @@ async def test_gateway_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", gateway_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_gateway_list_by_service(self, resource_group): + response = self.client.gateway.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_gateway_list_keys(self, resource_group): @@ -119,7 +147,6 @@ async def test_gateway_list_keys(self, resource_group): resource_group_name=resource_group.name, service_name="str", gateway_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -133,7 +160,6 @@ async def test_gateway_regenerate_key(self, resource_group): service_name="str", gateway_id="str", parameters={"keyType": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -147,7 +173,6 @@ async def test_gateway_generate_token(self, resource_group): service_name="str", gateway_id="str", parameters={"expiry": "2020-02-20 00:00:00", "keyType": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -160,7 +185,6 @@ async def test_gateway_invalidate_debug_credentials(self, resource_group): resource_group_name=resource_group.name, service_name="str", gateway_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -174,7 +198,6 @@ async def test_gateway_list_debug_credentials(self, resource_group): service_name="str", gateway_id="str", parameters={"apiId": "str", "purposes": ["str"], "credentialsExpireAfter": "1 day, 0:00:00"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -188,7 +211,6 @@ async def test_gateway_list_trace(self, resource_group): service_name="str", gateway_id="str", parameters={"traceId": "str"}, - api_version="2024-05-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 index 0a64c5e3afc6..b99e79da2e55 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_global_schema_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_global_schema_get_entity_tag(self, resource_group): - response = self.client.global_schema.get_entity_tag( + def test_global_schema_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-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_global_schema_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_global_schema_get(self, resource_group): - response = self.client.global_schema.get( + def test_global_schema_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-05-01", ) # please add some check logic here by yourself @@ -64,16 +50,25 @@ def test_global_schema_begin_create_or_update(self, resource_group): service_name="str", schema_id="str", parameters={ - "description": "str", - "document": {}, "id": "str", "name": "str", - "provisioningState": "str", - "schemaType": "str", + "properties": { + "schemaType": "str", + "description": "str", + "document": {}, + "provisioningState": "str", + "value": {}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "value": {}, }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -86,9 +81,20 @@ def test_global_schema_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", schema_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_global_schema_list_by_service(self, resource_group): + response = self.client.global_schema.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_global_schema_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_global_schema_operations_async.py index 03f0dbe5d099..d03e48c81342 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_global_schema_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-05-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_global_schema_get_entity_tag(self, resource_group): - response = await self.client.global_schema.get_entity_tag( + async def test_global_schema_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_global_schema_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_global_schema_get(self, resource_group): - response = await self.client.global_schema.get( + async def test_global_schema_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-05-01", ) # please add some check logic here by yourself @@ -66,16 +52,25 @@ async def test_global_schema_begin_create_or_update(self, resource_group): service_name="str", schema_id="str", parameters={ - "description": "str", - "document": {}, "id": "str", "name": "str", - "provisioningState": "str", - "schemaType": "str", + "properties": { + "schemaType": "str", + "description": "str", + "document": {}, + "provisioningState": "str", + "value": {}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "value": {}, }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -89,9 +84,20 @@ async def test_global_schema_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", schema_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_global_schema_list_by_service(self, resource_group): + response = self.client.global_schema.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_graph_ql_api_resolver_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_graph_ql_api_resolver_operations.py index b617f9e2493b..bbaa92ef7000 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_graph_ql_api_resolver_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_graph_ql_api_resolver_get_entity_tag(self, resource_group): - response = self.client.graph_ql_api_resolver.get_entity_tag( + def test_graph_ql_api_resolver_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_graph_ql_api_resolver_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_graph_ql_api_resolver_get(self, resource_group): - response = self.client.graph_ql_api_resolver.get( + def test_graph_ql_api_resolver_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-05-01", ) # please add some check logic here by yourself @@ -68,14 +53,19 @@ def test_graph_ql_api_resolver_create_or_update(self, resource_group): api_id="str", resolver_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", "name": "str", - "path": "str", + "properties": {"description": "str", "displayName": "str", "path": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -89,9 +79,9 @@ def test_graph_ql_api_resolver_update(self, resource_group): service_name="str", api_id="str", resolver_id="str", - if_match="str", - parameters={"description": "str", "displayName": "str", "path": "str"}, - api_version="2024-05-01", + parameters={"properties": {"description": "str", "displayName": "str", "path": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -105,9 +95,21 @@ def test_graph_ql_api_resolver_delete(self, resource_group): service_name="str", api_id="str", resolver_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_graph_ql_api_resolver_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", + ) + 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_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 index 9d9a2848b11f..3c890cde9942 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_graph_ql_api_resolver_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-05-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_graph_ql_api_resolver_get_entity_tag(self, resource_group): - response = await self.client.graph_ql_api_resolver.get_entity_tag( + async def test_graph_ql_api_resolver_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_graph_ql_api_resolver_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_graph_ql_api_resolver_get(self, resource_group): - response = await self.client.graph_ql_api_resolver.get( + async def test_graph_ql_api_resolver_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-05-01", ) # please add some check logic here by yourself @@ -69,14 +54,19 @@ async def test_graph_ql_api_resolver_create_or_update(self, resource_group): api_id="str", resolver_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", "name": "str", - "path": "str", + "properties": {"description": "str", "displayName": "str", "path": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -90,9 +80,9 @@ async def test_graph_ql_api_resolver_update(self, resource_group): service_name="str", api_id="str", resolver_id="str", - if_match="str", - parameters={"description": "str", "displayName": "str", "path": "str"}, - api_version="2024-05-01", + parameters={"properties": {"description": "str", "displayName": "str", "path": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -106,9 +96,21 @@ async def test_graph_ql_api_resolver_delete(self, resource_group): service_name="str", api_id="str", resolver_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_graph_ql_api_resolver_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", + ) + 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_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 index f0a95e8e1829..9f53c6f2c9ba 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,15 +20,15 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_graph_ql_api_resolver_policy_list_by_resolver(self, resource_group): - response = self.client.graph_ql_api_resolver_policy.list_by_resolver( + def test_graph_ql_api_resolver_policy_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", - api_version="2024-05-01", + policy_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -41,7 +41,6 @@ def test_graph_ql_api_resolver_policy_get_entity_tag(self, resource_group): api_id="str", resolver_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -49,14 +48,27 @@ def test_graph_ql_api_resolver_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_graph_ql_api_resolver_policy_get(self, resource_group): - response = self.client.graph_ql_api_resolver_policy.get( + def test_graph_ql_api_resolver_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -64,15 +76,15 @@ def test_graph_ql_api_resolver_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_graph_ql_api_resolver_policy_create_or_update(self, resource_group): - response = self.client.graph_ql_api_resolver_policy.create_or_update( + def test_graph_ql_api_resolver_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -80,16 +92,13 @@ def test_graph_ql_api_resolver_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_graph_ql_api_resolver_policy_delete(self, resource_group): - response = self.client.graph_ql_api_resolver_policy.delete( + def test_graph_ql_api_resolver_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_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 index 13918bb0712c..68fe82d9807f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,15 +21,15 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_graph_ql_api_resolver_policy_list_by_resolver(self, resource_group): - response = self.client.graph_ql_api_resolver_policy.list_by_resolver( + async def test_graph_ql_api_resolver_policy_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", - api_version="2024-05-01", + policy_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -42,7 +42,6 @@ async def test_graph_ql_api_resolver_policy_get_entity_tag(self, resource_group) api_id="str", resolver_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -50,14 +49,27 @@ async def test_graph_ql_api_resolver_policy_get_entity_tag(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_graph_ql_api_resolver_policy_get(self, resource_group): - response = await self.client.graph_ql_api_resolver_policy.get( + async def test_graph_ql_api_resolver_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -65,15 +77,15 @@ async def test_graph_ql_api_resolver_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_graph_ql_api_resolver_policy_create_or_update(self, resource_group): - response = await self.client.graph_ql_api_resolver_policy.create_or_update( + async def test_graph_ql_api_resolver_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -81,16 +93,13 @@ async def test_graph_ql_api_resolver_policy_create_or_update(self, resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_graph_ql_api_resolver_policy_delete(self, resource_group): - response = await self.client.graph_ql_api_resolver_policy.delete( + async def test_graph_ql_api_resolver_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations.py index 60b45e076dbe..44e9e20ea0d1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_group_list_by_service(self, resource_group): - response = self.client.group.list_by_service( + def test_group_get(self, resource_group): + response = self.client.group.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + group_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -37,7 +37,6 @@ def test_group_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", group_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +44,12 @@ def test_group_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_group_get(self, resource_group): - response = self.client.group.get( + def test_group_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", - api_version="2024-05-01", + parameters={"properties": {"displayName": "str", "description": "str", "externalId": "str", "type": "str"}}, ) # please add some check logic here by yourself @@ -58,13 +57,14 @@ def test_group_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_group_create_or_update(self, resource_group): - response = self.client.group.create_or_update( + def test_group_update(self, resource_group): + response = self.client.group.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-05-01", + parameters={"properties": {"description": "str", "displayName": "str", "externalId": "str", "type": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -72,14 +72,13 @@ def test_group_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_group_update(self, resource_group): - response = self.client.group.update( + def test_group_delete(self, resource_group): + response = self.client.group.delete( 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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -87,14 +86,11 @@ def test_group_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_group_delete(self, resource_group): - response = self.client.group.delete( + def test_group_list_by_service(self, resource_group): + response = self.client.group.list_by_service( resource_group_name=resource_group.name, service_name="str", - group_id="str", - if_match="str", - api_version="2024-05-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_group_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_operations_async.py index b8deb7d97a77..7f057e65ba64 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_group_list_by_service(self, resource_group): - response = self.client.group.list_by_service( + async def test_group_get(self, resource_group): + response = await self.client.group.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + group_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -38,7 +38,6 @@ async def test_group_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", group_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,12 +45,12 @@ async def test_group_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_group_get(self, resource_group): - response = await self.client.group.get( + async def test_group_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", - api_version="2024-05-01", + parameters={"properties": {"displayName": "str", "description": "str", "externalId": "str", "type": "str"}}, ) # please add some check logic here by yourself @@ -59,13 +58,14 @@ async def test_group_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_group_create_or_update(self, resource_group): - response = await self.client.group.create_or_update( + async def test_group_update(self, resource_group): + response = await self.client.group.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-05-01", + parameters={"properties": {"description": "str", "displayName": "str", "externalId": "str", "type": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -73,14 +73,13 @@ async def test_group_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_group_update(self, resource_group): - response = await self.client.group.update( + async def test_group_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", - parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -88,14 +87,11 @@ async def test_group_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_group_delete(self, resource_group): - response = await self.client.group.delete( + async def test_group_list_by_service(self, resource_group): + response = self.client.group.list_by_service( resource_group_name=resource_group.name, service_name="str", - group_id="str", - if_match="str", - api_version="2024-05-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_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_group_user_operations.py index 9e364e61242d..b58b040ffe99 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_group_user_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", group_id="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -39,7 +38,6 @@ def test_group_user_check_entity_exists(self, resource_group): service_name="str", group_id="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -53,7 +51,6 @@ def test_group_user_create(self, resource_group): service_name="str", group_id="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -67,7 +64,6 @@ def test_group_user_delete(self, resource_group): service_name="str", group_id="str", user_id="str", - api_version="2024-05-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 index 31b366035b65..1511dbdeda4a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_group_user_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", group_id="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -40,7 +39,6 @@ async def test_group_user_check_entity_exists(self, resource_group): service_name="str", group_id="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -54,7 +52,6 @@ async def test_group_user_create(self, resource_group): service_name="str", group_id="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -68,7 +65,6 @@ async def test_group_user_delete(self, resource_group): service_name="str", group_id="str", user_id="str", - api_version="2024-05-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 index fdece69d4f73..450f2f790a98 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_identity_provider_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_identity_provider_get_entity_tag(self, resource_group): - response = self.client.identity_provider.get_entity_tag( + def test_identity_provider_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-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_identity_provider_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_identity_provider_get(self, resource_group): - response = self.client.identity_provider.get( + def test_identity_provider_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-05-01", ) # please add some check logic here by yourself @@ -64,21 +50,32 @@ def test_identity_provider_create_or_update(self, resource_group): 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", + "properties": { + "clientId": "str", + "clientSecret": "str", + "allowedTenants": ["str"], + "authority": "str", + "certificateId": "str", + "clientLibrary": "str", + "passwordResetPolicyName": "str", + "profileEditingPolicyName": "str", + "signinPolicyName": "str", + "signinTenant": "str", + "signupPolicyName": "str", + "type": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -91,21 +88,24 @@ def test_identity_provider_update(self, resource_group): 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", + "properties": { + "allowedTenants": ["str"], + "authority": "str", + "certificateId": "str", + "clientId": "str", + "clientLibrary": "str", + "clientSecret": "str", + "passwordResetPolicyName": "str", + "profileEditingPolicyName": "str", + "signinPolicyName": "str", + "signinTenant": "str", + "signupPolicyName": "str", + "type": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -118,13 +118,24 @@ def test_identity_provider_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", identity_provider_name="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_identity_provider_list_by_service(self, resource_group): + response = self.client.identity_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_identity_provider_list_secrets(self, resource_group): @@ -132,7 +143,6 @@ def test_identity_provider_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", identity_provider_name="str", - api_version="2024-05-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 index 912eb8dd0ede..25f4f4b88910 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_identity_provider_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-05-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_identity_provider_get_entity_tag(self, resource_group): - response = await self.client.identity_provider.get_entity_tag( + async def test_identity_provider_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_identity_provider_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_identity_provider_get(self, resource_group): - response = await self.client.identity_provider.get( + async def test_identity_provider_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-05-01", ) # please add some check logic here by yourself @@ -65,21 +51,32 @@ async def test_identity_provider_create_or_update(self, resource_group): 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", + "properties": { + "clientId": "str", + "clientSecret": "str", + "allowedTenants": ["str"], + "authority": "str", + "certificateId": "str", + "clientLibrary": "str", + "passwordResetPolicyName": "str", + "profileEditingPolicyName": "str", + "signinPolicyName": "str", + "signinTenant": "str", + "signupPolicyName": "str", + "type": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -92,21 +89,24 @@ async def test_identity_provider_update(self, resource_group): 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", + "properties": { + "allowedTenants": ["str"], + "authority": "str", + "certificateId": "str", + "clientId": "str", + "clientLibrary": "str", + "clientSecret": "str", + "passwordResetPolicyName": "str", + "profileEditingPolicyName": "str", + "signinPolicyName": "str", + "signinTenant": "str", + "signupPolicyName": "str", + "type": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -119,13 +119,24 @@ async def test_identity_provider_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", identity_provider_name="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_identity_provider_list_by_service(self, resource_group): + response = self.client.identity_provider.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_identity_provider_list_secrets(self, resource_group): @@ -133,7 +144,6 @@ async def test_identity_provider_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", identity_provider_name="str", - api_version="2024-05-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 index 6db71e7d1ae8..4c6d94d5795f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_issue_list_by_service(self, resource_group): - response = self.client.issue.list_by_service( + def test_issue_get(self, resource_group): + response = self.client.issue.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + issue_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_issue_get(self, resource_group): - response = self.client.issue.get( + def test_issue_list_by_service(self, resource_group): + response = self.client.issue.list_by_service( resource_group_name=resource_group.name, service_name="str", - issue_id="str", - api_version="2024-05-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_issue_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_issue_operations_async.py index f100d2f97bc5..1c759e1a18dc 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_issue_list_by_service(self, resource_group): - response = self.client.issue.list_by_service( + async def test_issue_get(self, resource_group): + response = await self.client.issue.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + issue_id="str", ) - 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_issue_get(self, resource_group): - response = await self.client.issue.get( + async def test_issue_list_by_service(self, resource_group): + response = self.client.issue.list_by_service( resource_group_name=resource_group.name, service_name="str", - issue_id="str", - api_version="2024-05-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_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations.py index de8356b4c36b..1cddcbc781b3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_logger_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_logger_get_entity_tag(self, resource_group): - response = self.client.logger.get_entity_tag( + def test_logger_get(self, resource_group): + response = self.client.logger.get( resource_group_name=resource_group.name, service_name="str", logger_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_logger_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_logger_get(self, resource_group): - response = self.client.logger.get( + def test_logger_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-05-01", ) # please add some check logic here by yourself @@ -64,16 +50,25 @@ def test_logger_create_or_update(self, resource_group): service_name="str", logger_id="str", parameters={ - "credentials": {"str": "str"}, - "description": "str", "id": "str", - "isBuffered": bool, - "loggerType": "str", "name": "str", - "resourceId": "str", + "properties": { + "loggerType": "str", + "credentials": {"str": "str"}, + "description": "str", + "isBuffered": bool, + "resourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -86,9 +81,16 @@ def test_logger_update(self, resource_group): 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-05-01", + parameters={ + "properties": { + "credentials": {"str": "str"}, + "description": "str", + "isBuffered": bool, + "loggerType": "str", + } + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -101,9 +103,20 @@ def test_logger_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", logger_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_logger_list_by_service(self, resource_group): + response = self.client.logger.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_logger_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_logger_operations_async.py index 9741e779c0f0..989f609ea056 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_logger_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-05-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_logger_get_entity_tag(self, resource_group): - response = await self.client.logger.get_entity_tag( + async def test_logger_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_logger_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_logger_get(self, resource_group): - response = await self.client.logger.get( + async def test_logger_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-05-01", ) # please add some check logic here by yourself @@ -65,16 +51,25 @@ async def test_logger_create_or_update(self, resource_group): service_name="str", logger_id="str", parameters={ - "credentials": {"str": "str"}, - "description": "str", "id": "str", - "isBuffered": bool, - "loggerType": "str", "name": "str", - "resourceId": "str", + "properties": { + "loggerType": "str", + "credentials": {"str": "str"}, + "description": "str", + "isBuffered": bool, + "resourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -87,9 +82,16 @@ async def test_logger_update(self, resource_group): 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-05-01", + parameters={ + "properties": { + "credentials": {"str": "str"}, + "description": "str", + "isBuffered": bool, + "loggerType": "str", + } + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -102,9 +104,20 @@ async def test_logger_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", logger_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_logger_list_by_service(self, resource_group): + response = self.client.logger.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_named_value_operations.py index 210dea41b42f..5588643bb021 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_named_value_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_named_value_get_entity_tag(self, resource_group): - response = self.client.named_value.get_entity_tag( + def test_named_value_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-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_named_value_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_named_value_get(self, resource_group): - response = self.client.named_value.get( + def test_named_value_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-05-01", ) # please add some check logic here by yourself @@ -64,16 +50,25 @@ def test_named_value_begin_create_or_update(self, resource_group): service_name="str", named_value_id="str", parameters={ - "displayName": "str", "id": "str", - "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, "name": "str", - "secret": bool, - "tags": ["str"], + "properties": { + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -86,15 +81,17 @@ def test_named_value_begin_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -107,13 +104,24 @@ def test_named_value_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", named_value_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_named_value_list_by_service(self, resource_group): + response = self.client.named_value.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_named_value_list_value(self, resource_group): @@ -121,7 +129,6 @@ def test_named_value_list_value(self, resource_group): resource_group_name=resource_group.name, service_name="str", named_value_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -134,7 +141,6 @@ def test_named_value_begin_refresh_secret(self, resource_group): resource_group_name=resource_group.name, service_name="str", named_value_id="str", - api_version="2024-05-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 index 997dab2c27d6..9c9736c7fb26 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_named_value_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-05-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_named_value_get_entity_tag(self, resource_group): - response = await self.client.named_value.get_entity_tag( + async def test_named_value_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_named_value_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_named_value_get(self, resource_group): - response = await self.client.named_value.get( + async def test_named_value_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-05-01", ) # please add some check logic here by yourself @@ -66,16 +52,25 @@ async def test_named_value_begin_create_or_update(self, resource_group): service_name="str", named_value_id="str", parameters={ - "displayName": "str", "id": "str", - "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, "name": "str", - "secret": bool, - "tags": ["str"], + "properties": { + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -90,15 +85,17 @@ async def test_named_value_begin_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) ).result() # call '.result()' to poll until service return final result @@ -112,13 +109,24 @@ async def test_named_value_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", named_value_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_named_value_list_by_service(self, resource_group): + response = self.client.named_value.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_named_value_list_value(self, resource_group): @@ -126,7 +134,6 @@ async def test_named_value_list_value(self, resource_group): resource_group_name=resource_group.name, service_name="str", named_value_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -140,7 +147,6 @@ async def test_named_value_begin_refresh_secret(self, resource_group): resource_group_name=resource_group.name, service_name="str", named_value_id="str", - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result 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 index 485446d217b2..fd166d3a0bf1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_network_status_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-05-01", ) # please add some check logic here by yourself @@ -37,7 +36,6 @@ def test_network_status_list_by_location(self, resource_group): resource_group_name=resource_group.name, service_name="str", location_name="str", - api_version="2024-05-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 index cb2d7cf54ce4..4fbc54b54317 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_network_status_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-05-01", ) # please add some check logic here by yourself @@ -38,7 +37,6 @@ async def test_network_status_list_by_location(self, resource_group): resource_group_name=resource_group.name, service_name="str", location_name="str", - api_version="2024-05-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 index 8352fa27722f..3266d3b32d90 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_notification_list_by_service(self, resource_group): - response = self.client.notification.list_by_service( + def test_notification_get(self, resource_group): + response = self.client.notification.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + notification_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_notification_get(self, resource_group): - response = self.client.notification.get( + def test_notification_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-05-01", ) # please add some check logic here by yourself @@ -45,13 +44,11 @@ def test_notification_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_notification_create_or_update(self, resource_group): - response = self.client.notification.create_or_update( + def test_notification_list_by_service(self, resource_group): + response = self.client.notification.list_by_service( resource_group_name=resource_group.name, service_name="str", - notification_name="str", - api_version="2024-05-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_notification_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_operations_async.py index f6a253f69c3e..358dd5b92e88 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_notification_list_by_service(self, resource_group): - response = self.client.notification.list_by_service( + async def test_notification_get(self, resource_group): + response = await self.client.notification.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + notification_name="str", ) - 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_notification_get(self, resource_group): - response = await self.client.notification.get( + async def test_notification_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-05-01", ) # please add some check logic here by yourself @@ -46,13 +45,11 @@ async def test_notification_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_notification_create_or_update(self, resource_group): - response = await self.client.notification.create_or_update( + async def test_notification_list_by_service(self, resource_group): + response = self.client.notification.list_by_service( resource_group_name=resource_group.name, service_name="str", - notification_name="str", - api_version="2024-05-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_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_notification_recipient_email_operations.py index 3342307215db..a1fd5e8da69e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_notification_recipient_email_list_by_notification(self, resource_group) resource_group_name=resource_group.name, service_name="str", notification_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -39,7 +38,6 @@ def test_notification_recipient_email_check_entity_exists(self, resource_group): service_name="str", notification_name="str", email="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -53,7 +51,6 @@ def test_notification_recipient_email_create_or_update(self, resource_group): service_name="str", notification_name="str", email="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -67,7 +64,6 @@ def test_notification_recipient_email_delete(self, resource_group): service_name="str", notification_name="str", email="str", - api_version="2024-05-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 index 9b5e4f786e4c..0e3a4bc685e7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_notification_recipient_email_list_by_notification(self, resource_ resource_group_name=resource_group.name, service_name="str", notification_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -40,7 +39,6 @@ async def test_notification_recipient_email_check_entity_exists(self, resource_g service_name="str", notification_name="str", email="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -54,7 +52,6 @@ async def test_notification_recipient_email_create_or_update(self, resource_grou service_name="str", notification_name="str", email="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -68,7 +65,6 @@ async def test_notification_recipient_email_delete(self, resource_group): service_name="str", notification_name="str", email="str", - api_version="2024-05-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 index 0d7350acbb5b..09c44893299e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_notification_recipient_user_list_by_notification(self, resource_group): resource_group_name=resource_group.name, service_name="str", notification_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -39,7 +38,6 @@ def test_notification_recipient_user_check_entity_exists(self, resource_group): service_name="str", notification_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -53,7 +51,6 @@ def test_notification_recipient_user_create_or_update(self, resource_group): service_name="str", notification_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -67,7 +64,6 @@ def test_notification_recipient_user_delete(self, resource_group): service_name="str", notification_name="str", user_id="str", - api_version="2024-05-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 index 29c260fd56da..f9144250598c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_notification_recipient_user_list_by_notification(self, resource_g resource_group_name=resource_group.name, service_name="str", notification_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -40,7 +39,6 @@ async def test_notification_recipient_user_check_entity_exists(self, resource_gr service_name="str", notification_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -54,7 +52,6 @@ async def test_notification_recipient_user_create_or_update(self, resource_group service_name="str", notification_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -68,7 +65,6 @@ async def test_notification_recipient_user_delete(self, resource_group): service_name="str", notification_name="str", user_id="str", - api_version="2024-05-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 index 75eb6caea7de..b2f02b0c6f7b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_open_id_connect_provider_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_open_id_connect_provider_get_entity_tag(self, resource_group): - response = self.client.open_id_connect_provider.get_entity_tag( + def test_open_id_connect_provider_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-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_open_id_connect_provider_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_open_id_connect_provider_get(self, resource_group): - response = self.client.open_id_connect_provider.get( + def test_open_id_connect_provider_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-05-01", ) # please add some check logic here by yourself @@ -64,18 +50,27 @@ def test_open_id_connect_provider_create_or_update(self, resource_group): service_name="str", opid="str", parameters={ - "clientId": "str", - "clientSecret": "str", - "description": "str", - "displayName": "str", "id": "str", - "metadataEndpoint": "str", "name": "str", + "properties": { + "clientId": "str", + "displayName": "str", + "metadataEndpoint": "str", + "clientSecret": "str", + "description": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "useInApiDocumentation": bool, - "useInTestConsole": bool, }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -88,17 +83,19 @@ def test_open_id_connect_provider_update(self, resource_group): 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, + "properties": { + "clientId": "str", + "clientSecret": "str", + "description": "str", + "displayName": "str", + "metadataEndpoint": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -111,13 +108,24 @@ def test_open_id_connect_provider_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", opid="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_open_id_connect_provider_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", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_open_id_connect_provider_list_secrets(self, resource_group): @@ -125,7 +133,6 @@ def test_open_id_connect_provider_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", opid="str", - api_version="2024-05-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 index fef7919b6949..6e52c40af51a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_open_id_connect_provider_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-05-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_open_id_connect_provider_get_entity_tag(self, resource_group): - response = await self.client.open_id_connect_provider.get_entity_tag( + async def test_open_id_connect_provider_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_open_id_connect_provider_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_open_id_connect_provider_get(self, resource_group): - response = await self.client.open_id_connect_provider.get( + async def test_open_id_connect_provider_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-05-01", ) # please add some check logic here by yourself @@ -65,18 +51,27 @@ async def test_open_id_connect_provider_create_or_update(self, resource_group): service_name="str", opid="str", parameters={ - "clientId": "str", - "clientSecret": "str", - "description": "str", - "displayName": "str", "id": "str", - "metadataEndpoint": "str", "name": "str", + "properties": { + "clientId": "str", + "displayName": "str", + "metadataEndpoint": "str", + "clientSecret": "str", + "description": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "useInApiDocumentation": bool, - "useInTestConsole": bool, }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -89,17 +84,19 @@ async def test_open_id_connect_provider_update(self, resource_group): 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, + "properties": { + "clientId": "str", + "clientSecret": "str", + "description": "str", + "displayName": "str", + "metadataEndpoint": "str", + "useInApiDocumentation": bool, + "useInTestConsole": bool, + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -112,13 +109,24 @@ async def test_open_id_connect_provider_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", opid="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_open_id_connect_provider_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", + ) + 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_open_id_connect_provider_list_secrets(self, resource_group): @@ -126,7 +134,6 @@ async def test_open_id_connect_provider_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", opid="str", - api_version="2024-05-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 index 521c479bc87f..8b4c0a4ff3c7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_operation_list_by_tags(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-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 index 5320b562093c..c77fe7c2ffac 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_operation_list_by_tags(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-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 index ebee9a2989e1..b563b98e790b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_operation_status_get(self, resource_group): response = self.client.operation_status.get( location="str", operation_id="str", - api_version="2024-05-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 index 16251eec8d47..b33242dd941f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_operation_status_get(self, resource_group): response = await self.client.operation_status.get( location="str", operation_id="str", - api_version="2024-05-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 index d7a4dda5cdb3..483365b1ee65 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_operations_results_get(self, resource_group): response = self.client.operations_results.get( location="str", operation_id="str", - api_version="2024-05-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 index bed3f33fc7eb..cf1d018349ac 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_operations_results_get(self, resource_group): response = await self.client.operations_results.get( location="str", operation_id="str", - api_version="2024-05-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 index 21324c68d5f9..e379341dadf2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_outbound_network_dependencies_endpoints_list_by_service(self, resource_ response = self.client.outbound_network_dependencies_endpoints.list_by_service( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-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 index 040489551800..345eb789aa3c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_outbound_network_dependencies_endpoints_list_by_service(self, res response = await self.client.outbound_network_dependencies_endpoints.list_by_service( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-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 index b7be819db0a6..2f980eb3c335 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_policy_description_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-05-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 index 54fa5b45bb29..68b5aa4ae7ac 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_policy_description_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-05-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 index c01561327d34..7612a48e5bcb 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_fragment_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_policy_fragment_get_entity_tag(self, resource_group): - response = self.client.policy_fragment.get_entity_tag( + def test_policy_fragment_get(self, resource_group): + response = self.client.policy_fragment.get( resource_group_name=resource_group.name, service_name="str", id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_policy_fragment_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_fragment_get(self, resource_group): - response = self.client.policy_fragment.get( + def test_policy_fragment_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-05-01", ) # please add some check logic here by yourself @@ -64,15 +50,19 @@ def test_policy_fragment_begin_create_or_update(self, resource_group): service_name="str", id="str", parameters={ - "description": "str", - "format": "str", "id": "str", "name": "str", - "provisioningState": "str", + "properties": {"value": "str", "description": "str", "format": "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", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -85,13 +75,24 @@ def test_policy_fragment_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_fragment_list_by_service(self, resource_group): + response = self.client.policy_fragment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_policy_fragment_list_references(self, resource_group): @@ -99,7 +100,6 @@ def test_policy_fragment_list_references(self, resource_group): resource_group_name=resource_group.name, service_name="str", id="str", - api_version="2024-05-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 index 36e5581c972d..c5e7b5df3703 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_fragment_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-05-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_policy_fragment_get_entity_tag(self, resource_group): - response = await self.client.policy_fragment.get_entity_tag( + async def test_policy_fragment_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_policy_fragment_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_fragment_get(self, resource_group): - response = await self.client.policy_fragment.get( + async def test_policy_fragment_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-05-01", ) # please add some check logic here by yourself @@ -66,15 +52,19 @@ async def test_policy_fragment_begin_create_or_update(self, resource_group): service_name="str", id="str", parameters={ - "description": "str", - "format": "str", "id": "str", "name": "str", - "provisioningState": "str", + "properties": {"value": "str", "description": "str", "format": "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", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -88,13 +78,24 @@ async def test_policy_fragment_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_fragment_list_by_service(self, resource_group): + response = self.client.policy_fragment.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_policy_fragment_list_references(self, resource_group): @@ -102,7 +103,6 @@ async def test_policy_fragment_list_references(self, resource_group): resource_group_name=resource_group.name, service_name="str", id="str", - api_version="2024-05-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 index 0f148897f1f2..6fafb9a84074 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_list_by_service(self, resource_group): - response = self.client.policy.list_by_service( + def test_policy_get(self, resource_group): + response = self.client.policy.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + policy_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -37,7 +37,6 @@ def test_policy_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +44,25 @@ def test_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_get(self, resource_group): - response = self.client.policy.get( + def test_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -58,13 +70,13 @@ def test_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_create_or_update(self, resource_group): - response = self.client.policy.create_or_update( + def test_policy_delete(self, resource_group): + response = self.client.policy.delete( 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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -72,14 +84,11 @@ def test_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_delete(self, resource_group): - response = self.client.policy.delete( + def test_policy_list_by_service(self, resource_group): + response = self.client.policy.list_by_service( resource_group_name=resource_group.name, service_name="str", - policy_id="str", - if_match="str", - api_version="2024-05-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_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_operations_async.py index 9b862dcf2a49..90fccc7cd8bc 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_list_by_service(self, resource_group): - response = self.client.policy.list_by_service( + async def test_policy_get(self, resource_group): + response = await self.client.policy.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + policy_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -38,7 +38,6 @@ async def test_policy_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,12 +45,25 @@ async def test_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_get(self, resource_group): - response = await self.client.policy.get( + async def test_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -59,13 +71,13 @@ async def test_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_create_or_update(self, resource_group): - response = await self.client.policy.create_or_update( + async def test_policy_delete(self, resource_group): + response = await self.client.policy.delete( 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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -73,14 +85,11 @@ async def test_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_delete(self, resource_group): - response = await self.client.policy.delete( + async def test_policy_list_by_service(self, resource_group): + response = self.client.policy.list_by_service( resource_group_name=resource_group.name, service_name="str", - policy_id="str", - if_match="str", - api_version="2024-05-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_policy_restriction_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations.py index f25a30c37fc0..e1569eabf289 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_restriction_list_by_service(self, resource_group): - response = self.client.policy_restriction.list_by_service( + def test_policy_restriction_get(self, resource_group): + response = self.client.policy_restriction.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + policy_restriction_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -37,7 +37,6 @@ def test_policy_restriction_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", policy_restriction_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +44,25 @@ def test_policy_restriction_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_restriction_get(self, resource_group): - response = self.client.policy_restriction.get( + def test_policy_restriction_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"requireBase": "str", "scope": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -58,13 +70,14 @@ def test_policy_restriction_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_restriction_create_or_update(self, resource_group): - response = self.client.policy_restriction.create_or_update( + def test_policy_restriction_update(self, resource_group): + response = self.client.policy_restriction.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-05-01", + parameters={"properties": {"requireBase": "str", "scope": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -72,14 +85,11 @@ def test_policy_restriction_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_restriction_update(self, resource_group): - response = self.client.policy_restriction.update( + def test_policy_restriction_delete(self, resource_group): + response = self.client.policy_restriction.delete( resource_group_name=resource_group.name, service_name="str", policy_restriction_id="str", - if_match="str", - parameters={"requireBase": "false", "scope": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -87,13 +97,11 @@ def test_policy_restriction_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_policy_restriction_delete(self, resource_group): - response = self.client.policy_restriction.delete( + def test_policy_restriction_list_by_service(self, resource_group): + response = self.client.policy_restriction.list_by_service( resource_group_name=resource_group.name, service_name="str", - policy_restriction_id="str", - api_version="2024-05-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_policy_restriction_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_operations_async.py index 1f53cf53c167..b89a42ac7905 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_restriction_list_by_service(self, resource_group): - response = self.client.policy_restriction.list_by_service( + async def test_policy_restriction_get(self, resource_group): + response = await self.client.policy_restriction.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + policy_restriction_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -38,7 +38,6 @@ async def test_policy_restriction_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", policy_restriction_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,12 +45,25 @@ async def test_policy_restriction_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_restriction_get(self, resource_group): - response = await self.client.policy_restriction.get( + async def test_policy_restriction_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"requireBase": "str", "scope": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -59,13 +71,14 @@ async def test_policy_restriction_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_restriction_create_or_update(self, resource_group): - response = await self.client.policy_restriction.create_or_update( + async def test_policy_restriction_update(self, resource_group): + response = await self.client.policy_restriction.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-05-01", + parameters={"properties": {"requireBase": "str", "scope": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -73,14 +86,11 @@ async def test_policy_restriction_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_restriction_update(self, resource_group): - response = await self.client.policy_restriction.update( + async def test_policy_restriction_delete(self, resource_group): + response = await self.client.policy_restriction.delete( resource_group_name=resource_group.name, service_name="str", policy_restriction_id="str", - if_match="str", - parameters={"requireBase": "false", "scope": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -88,13 +98,11 @@ async def test_policy_restriction_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_policy_restriction_delete(self, resource_group): - response = await self.client.policy_restriction.delete( + async def test_policy_restriction_list_by_service(self, resource_group): + response = self.client.policy_restriction.list_by_service( resource_group_name=resource_group.name, service_name="str", - policy_restriction_id="str", - api_version="2024-05-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_policy_restriction_validations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_policy_restriction_validations_operations.py index 797cde4b2da3..90e0b369728e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_policy_restriction_validations_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-05-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 index 0c62ce2c9d63..4ae534e01c9b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_policy_restriction_validations_begin_by_service(self, resource_gr await self.client.policy_restriction_validations.begin_by_service( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result 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 index a3def173d611..264e02058e70 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_portal_config_list_by_service(self, resource_group): - response = self.client.portal_config.list_by_service( + def test_portal_config_get(self, resource_group): + response = self.client.portal_config.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + portal_config_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -37,7 +37,6 @@ def test_portal_config_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", portal_config_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +44,39 @@ def test_portal_config_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_portal_config_get(self, resource_group): - response = self.client.portal_config.get( + def test_portal_config_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": { + "cors": {"allowedOrigins": ["str"]}, + "csp": {"allowedSources": ["str"], "mode": "str", "reportUri": ["str"]}, + "delegation": { + "delegateRegistration": bool, + "delegateSubscription": bool, + "delegationUrl": "str", + "validationKey": "str", + }, + "enableBasicAuth": bool, + "signin": {"require": bool}, + "signup": {"termsOfService": {"requireConsent": bool, "text": "str"}}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -63,24 +89,34 @@ def test_portal_config_update(self, resource_group): 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"}}, + "properties": { + "cors": {"allowedOrigins": ["str"]}, + "csp": {"allowedSources": ["str"], "mode": "str", "reportUri": ["str"]}, + "delegation": { + "delegateRegistration": bool, + "delegateSubscription": bool, + "delegationUrl": "str", + "validationKey": "str", + }, + "enableBasicAuth": bool, + "signin": {"require": bool}, + "signup": {"termsOfService": {"requireConsent": bool, "text": "str"}}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -88,30 +124,11 @@ def test_portal_config_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_portal_config_create_or_update(self, resource_group): - response = self.client.portal_config.create_or_update( + def test_portal_config_list_by_service(self, resource_group): + response = self.client.portal_config.list_by_service( 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-05-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_portal_config_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_config_operations_async.py index 37ee3a5b328f..4e03bc4584bb 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_portal_config_list_by_service(self, resource_group): - response = self.client.portal_config.list_by_service( + async def test_portal_config_get(self, resource_group): + response = await self.client.portal_config.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + portal_config_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -38,7 +38,6 @@ async def test_portal_config_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", portal_config_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,12 +45,39 @@ async def test_portal_config_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_portal_config_get(self, resource_group): - response = await self.client.portal_config.get( + async def test_portal_config_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": { + "cors": {"allowedOrigins": ["str"]}, + "csp": {"allowedSources": ["str"], "mode": "str", "reportUri": ["str"]}, + "delegation": { + "delegateRegistration": bool, + "delegateSubscription": bool, + "delegationUrl": "str", + "validationKey": "str", + }, + "enableBasicAuth": bool, + "signin": {"require": bool}, + "signup": {"termsOfService": {"requireConsent": bool, "text": "str"}}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -64,24 +90,34 @@ async def test_portal_config_update(self, resource_group): 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"}}, + "properties": { + "cors": {"allowedOrigins": ["str"]}, + "csp": {"allowedSources": ["str"], "mode": "str", "reportUri": ["str"]}, + "delegation": { + "delegateRegistration": bool, + "delegateSubscription": bool, + "delegationUrl": "str", + "validationKey": "str", + }, + "enableBasicAuth": bool, + "signin": {"require": bool}, + "signup": {"termsOfService": {"requireConsent": bool, "text": "str"}}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -89,30 +125,11 @@ async def test_portal_config_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_portal_config_create_or_update(self, resource_group): - response = await self.client.portal_config.create_or_update( + async def test_portal_config_list_by_service(self, resource_group): + response = self.client.portal_config.list_by_service( 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-05-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_portal_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations.py index 0004f6e7b2d7..2219dff04581 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_portal_revision_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_portal_revision_get_entity_tag(self, resource_group): - response = self.client.portal_revision.get_entity_tag( + def test_portal_revision_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-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_portal_revision_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_portal_revision_get(self, resource_group): - response = self.client.portal_revision.get( + def test_portal_revision_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-05-01", ) # please add some check logic here by yourself @@ -64,18 +50,27 @@ def test_portal_revision_begin_create_or_update(self, resource_group): 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", + "properties": { + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "isCurrent": bool, + "provisioningState": "str", + "status": "str", + "statusDetails": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -88,21 +83,42 @@ def test_portal_revision_begin_update(self, resource_group): 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", + "properties": { + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "isCurrent": bool, + "provisioningState": "str", + "status": "str", + "statusDetails": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ).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_portal_revision_list_by_service(self, resource_group): + response = self.client.portal_revision.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_portal_revision_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_revision_operations_async.py index c03d2289e98c..a1eabdd812dd 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_portal_revision_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-05-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_portal_revision_get_entity_tag(self, resource_group): - response = await self.client.portal_revision.get_entity_tag( + async def test_portal_revision_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_portal_revision_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_portal_revision_get(self, resource_group): - response = await self.client.portal_revision.get( + async def test_portal_revision_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-05-01", ) # please add some check logic here by yourself @@ -66,18 +52,27 @@ async def test_portal_revision_begin_create_or_update(self, resource_group): 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", + "properties": { + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "isCurrent": bool, + "provisioningState": "str", + "status": "str", + "statusDetails": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -92,22 +87,43 @@ async def test_portal_revision_begin_update(self, resource_group): 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", + "properties": { + "createdDateTime": "2020-02-20 00:00:00", + "description": "str", + "isCurrent": bool, + "provisioningState": "str", + "status": "str", + "statusDetails": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) ).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_portal_revision_list_by_service(self, resource_group): + response = self.client.portal_revision.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_portal_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_portal_settings_operations.py index a2b85cf6ed61..42a6cd6ffc29 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_portal_settings_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-05-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 index 5efbc0415f5f..e8d9a38f3042 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_portal_settings_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-05-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 index dba082e834eb..3b773906cd71 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -18,18 +18,6 @@ class TestApiManagementPrivateEndpointConnectionOperations(AzureMgmtRecordedTest def setup_method(self, method): self.client = self.create_mgmt_client(ApiManagementClient) - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_private_endpoint_connection_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_private_endpoint_connection_get_by_name(self, resource_group): @@ -37,7 +25,6 @@ def test_private_endpoint_connection_get_by_name(self, resource_group): resource_group_name=resource_group.name, service_name="str", private_endpoint_connection_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -60,7 +47,6 @@ def test_private_endpoint_connection_begin_create_or_update(self, resource_group } }, }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -73,7 +59,6 @@ def test_private_endpoint_connection_begin_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", private_endpoint_connection_name="str", - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -81,13 +66,12 @@ def test_private_endpoint_connection_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_private_endpoint_connection_list_private_link_resources(self, resource_group): - response = self.client.private_endpoint_connection.list_private_link_resources( + def test_private_endpoint_connection_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-05-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -98,7 +82,17 @@ def test_private_endpoint_connection_get_private_link_resource(self, resource_gr resource_group_name=resource_group.name, service_name="str", private_link_sub_resource_name="str", - api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_private_endpoint_connection_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", ) # 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 index 4c862308e088..473c7b605153 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -19,18 +19,6 @@ class TestApiManagementPrivateEndpointConnectionOperationsAsync(AzureMgmtRecorde 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_private_endpoint_connection_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-05-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_private_endpoint_connection_get_by_name(self, resource_group): @@ -38,7 +26,6 @@ async def test_private_endpoint_connection_get_by_name(self, resource_group): resource_group_name=resource_group.name, service_name="str", private_endpoint_connection_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -62,7 +49,6 @@ async def test_private_endpoint_connection_begin_create_or_update(self, resource } }, }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -77,7 +63,6 @@ async def test_private_endpoint_connection_begin_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", private_endpoint_connection_name="str", - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -86,13 +71,12 @@ async def test_private_endpoint_connection_begin_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_private_endpoint_connection_list_private_link_resources(self, resource_group): - response = await self.client.private_endpoint_connection.list_private_link_resources( + async def test_private_endpoint_connection_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-05-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -103,7 +87,17 @@ async def test_private_endpoint_connection_get_private_link_resource(self, resou resource_group_name=resource_group.name, service_name="str", private_link_sub_resource_name="str", - api_version="2024-05-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_private_endpoint_connection_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", ) # 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 index 428fc96a40d2..c1895f469c67 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_api_link_list_by_product(self, resource_group): - response = self.client.product_api_link.list_by_product( + def test_product_api_link_get(self, resource_group): + response = self.client.product_api_link.get( resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", + api_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_api_link_get(self, resource_group): - response = self.client.product_api_link.get( + def test_product_api_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"apiId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -47,14 +60,12 @@ def test_product_api_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_api_link_create_or_update(self, resource_group): - response = self.client.product_api_link.create_or_update( + def test_product_api_link_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", - parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -62,14 +73,12 @@ def test_product_api_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_api_link_delete(self, resource_group): - response = self.client.product_api_link.delete( + def test_product_api_link_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_link_id="str", - api_version="2024-05-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_api_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_link_operations_async.py index 15ea0269bd93..94ba561a1d95 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_api_link_list_by_product(self, resource_group): - response = self.client.product_api_link.list_by_product( + async def test_product_api_link_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_version="2024-05-01", + api_link_id="str", ) - 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_product_api_link_get(self, resource_group): - response = await self.client.product_api_link.get( + async def test_product_api_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"apiId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -48,14 +61,12 @@ async def test_product_api_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_api_link_create_or_update(self, resource_group): - response = await self.client.product_api_link.create_or_update( + async def test_product_api_link_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", - parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -63,14 +74,12 @@ async def test_product_api_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_api_link_delete(self, resource_group): - response = await self.client.product_api_link.delete( + async def test_product_api_link_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_link_id="str", - api_version="2024-05-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_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_api_operations.py index 2db156c81e6d..e1bc6ccc21df 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_product_api_list_by_product(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -39,7 +38,6 @@ def test_product_api_check_entity_exists(self, resource_group): service_name="str", product_id="str", api_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -53,7 +51,6 @@ def test_product_api_create_or_update(self, resource_group): service_name="str", product_id="str", api_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -67,7 +64,6 @@ def test_product_api_delete(self, resource_group): service_name="str", product_id="str", api_id="str", - api_version="2024-05-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 index 19ed59a97a01..0bdbf7ea8531 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_product_api_list_by_product(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -40,7 +39,6 @@ async def test_product_api_check_entity_exists(self, resource_group): service_name="str", product_id="str", api_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -54,7 +52,6 @@ async def test_product_api_create_or_update(self, resource_group): service_name="str", product_id="str", api_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -68,7 +65,6 @@ async def test_product_api_delete(self, resource_group): service_name="str", product_id="str", api_id="str", - api_version="2024-05-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 index 0e2dff7236da..db8031e493fe 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_group_link_list_by_product(self, resource_group): - response = self.client.product_group_link.list_by_product( + def test_product_group_link_get(self, resource_group): + response = self.client.product_group_link.get( resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", + group_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_group_link_get(self, resource_group): - response = self.client.product_group_link.get( + def test_product_group_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"groupId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -47,14 +60,12 @@ def test_product_group_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_group_link_create_or_update(self, resource_group): - response = self.client.product_group_link.create_or_update( + def test_product_group_link_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", - parameters={"groupId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -62,14 +73,12 @@ def test_product_group_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_group_link_delete(self, resource_group): - response = self.client.product_group_link.delete( + def test_product_group_link_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", - group_link_id="str", - api_version="2024-05-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_group_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_link_operations_async.py index 20771a695897..eaed62e3a08b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_group_link_list_by_product(self, resource_group): - response = self.client.product_group_link.list_by_product( + async def test_product_group_link_get(self, resource_group): + response = await self.client.product_group_link.get( resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", + group_link_id="str", ) - 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_product_group_link_get(self, resource_group): - response = await self.client.product_group_link.get( + async def test_product_group_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"groupId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -48,14 +61,12 @@ async def test_product_group_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_group_link_create_or_update(self, resource_group): - response = await self.client.product_group_link.create_or_update( + async def test_product_group_link_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", - parameters={"groupId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -63,14 +74,12 @@ async def test_product_group_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_group_link_delete(self, resource_group): - response = await self.client.product_group_link.delete( + async def test_product_group_link_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", - group_link_id="str", - api_version="2024-05-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_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_group_operations.py index 5f4cc2afc428..4521e07a4e6b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_product_group_list_by_product(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -39,7 +38,6 @@ def test_product_group_check_entity_exists(self, resource_group): service_name="str", product_id="str", group_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -53,7 +51,6 @@ def test_product_group_create_or_update(self, resource_group): service_name="str", product_id="str", group_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -67,7 +64,6 @@ def test_product_group_delete(self, resource_group): service_name="str", product_id="str", group_id="str", - api_version="2024-05-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 index 34d8dc6471ff..6d0848463b77 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_product_group_list_by_product(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -40,7 +39,6 @@ async def test_product_group_check_entity_exists(self, resource_group): service_name="str", product_id="str", group_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -54,7 +52,6 @@ async def test_product_group_create_or_update(self, resource_group): service_name="str", product_id="str", group_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -68,7 +65,6 @@ async def test_product_group_delete(self, resource_group): service_name="str", product_id="str", group_id="str", - api_version="2024-05-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 index 1cb10f80b36f..b51431542903 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,11 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_list_by_service(self, resource_group): - response = self.client.product.list_by_service( + def test_product_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-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -32,12 +31,11 @@ def test_product_list_by_service(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_get_entity_tag(self, resource_group): - response = self.client.product.get_entity_tag( + def test_product_get(self, resource_group): + response = self.client.product.get( resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +43,11 @@ def test_product_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_get(self, resource_group): - response = self.client.product.get( + def test_product_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-05-01", ) # please add some check logic here by yourself @@ -64,18 +61,29 @@ def test_product_create_or_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "application": {"entra": {"applicationId": "str", "audience": "str"}}, + "approvalRequired": bool, + "authenticationType": ["str"], + "description": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -88,17 +96,21 @@ def test_product_update(self, resource_group): 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", + "properties": { + "application": {"entra": {"applicationId": "str", "audience": "str"}}, + "approvalRequired": bool, + "authenticationType": ["str"], + "description": "str", + "displayName": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -111,8 +123,8 @@ def test_product_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -120,11 +132,10 @@ def test_product_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_list_by_tags(self, resource_group): - response = self.client.product.list_by_tags( + def test_product_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-05-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 index 05564f5d8de7..941227839c5f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,11 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_list_by_service(self, resource_group): - response = self.client.product.list_by_service( + async def test_product_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-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -33,12 +32,11 @@ async def test_product_list_by_service(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_get_entity_tag(self, resource_group): - response = await self.client.product.get_entity_tag( + async def test_product_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +44,11 @@ async def test_product_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_get(self, resource_group): - response = await self.client.product.get( + async def test_product_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-05-01", ) # please add some check logic here by yourself @@ -65,18 +62,29 @@ async def test_product_create_or_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "application": {"entra": {"applicationId": "str", "audience": "str"}}, + "approvalRequired": bool, + "authenticationType": ["str"], + "description": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -89,17 +97,21 @@ async def test_product_update(self, resource_group): 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", + "properties": { + "application": {"entra": {"applicationId": "str", "audience": "str"}}, + "approvalRequired": bool, + "authenticationType": ["str"], + "description": "str", + "displayName": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -112,8 +124,8 @@ async def test_product_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -121,11 +133,10 @@ async def test_product_delete(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_list_by_tags(self, resource_group): - response = self.client.product.list_by_tags( + async def test_product_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-05-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 index 1ef463296a84..4a11ea84a519 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_policy_list_by_product(self, resource_group): - response = self.client.product_policy.list_by_product( + def test_product_policy_get(self, resource_group): + response = self.client.product_policy.get( resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", + policy_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -39,7 +39,6 @@ def test_product_policy_get_entity_tag(self, resource_group): service_name="str", product_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,26 @@ def test_product_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_policy_get(self, resource_group): - response = self.client.product_policy.get( + def test_product_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -61,14 +73,14 @@ def test_product_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_policy_create_or_update(self, resource_group): - response = self.client.product_policy.create_or_update( + def test_product_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -76,15 +88,12 @@ def test_product_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_policy_delete(self, resource_group): - response = self.client.product_policy.delete( + def test_product_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_policy_operations_async.py index 5c2757bfb83d..fd14586f8c9b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_policy_list_by_product(self, resource_group): - response = self.client.product_policy.list_by_product( + async def test_product_policy_get(self, resource_group): + response = await self.client.product_policy.get( resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-01", + policy_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +40,6 @@ async def test_product_policy_get_entity_tag(self, resource_group): service_name="str", product_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,26 @@ async def test_product_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_policy_get(self, resource_group): - response = await self.client.product_policy.get( + async def test_product_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -62,14 +74,14 @@ async def test_product_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_policy_create_or_update(self, resource_group): - response = await self.client.product_policy.create_or_update( + async def test_product_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -77,15 +89,12 @@ async def test_product_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_policy_delete(self, resource_group): - response = await self.client.product_policy.delete( + async def test_product_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_subscriptions_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_product_subscriptions_operations.py index a1c331048560..c8f64590865c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_product_subscriptions_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-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 index 2f8a253de483..5275250d70ea 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_product_subscriptions_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-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 index afa115909b19..73a049f9887e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,12 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_wiki_get_entity_tag(self, resource_group): - response = self.client.product_wiki.get_entity_tag( + def test_product_wiki_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-05-01", ) # please add some check logic here by yourself @@ -33,12 +32,11 @@ def test_product_wiki_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_product_wiki_get(self, resource_group): - response = self.client.product_wiki.get( + def test_product_wiki_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-05-01", ) # please add some check logic here by yourself @@ -51,8 +49,20 @@ def test_product_wiki_create_or_update(self, resource_group): 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-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"documents": [{"documentationId": "str"}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -65,9 +75,9 @@ def test_product_wiki_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - if_match="str", - parameters={"documents": [{"documentationId": "str"}]}, - api_version="2024-05-01", + parameters={"properties": {"documents": [{"documentationId": "str"}]}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -80,8 +90,8 @@ def test_product_wiki_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # 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 index 9f96940c593f..0d2aa393a326 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,12 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_wiki_get_entity_tag(self, resource_group): - response = await self.client.product_wiki.get_entity_tag( + async def test_product_wiki_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-05-01", ) # please add some check logic here by yourself @@ -34,12 +33,11 @@ async def test_product_wiki_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_product_wiki_get(self, resource_group): - response = await self.client.product_wiki.get( + async def test_product_wiki_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-05-01", ) # please add some check logic here by yourself @@ -52,8 +50,20 @@ async def test_product_wiki_create_or_update(self, resource_group): 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-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"documents": [{"documentationId": "str"}]}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -66,9 +76,9 @@ async def test_product_wiki_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - if_match="str", - parameters={"documents": [{"documentationId": "str"}]}, - api_version="2024-05-01", + parameters={"properties": {"documents": [{"documentationId": "str"}]}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -81,8 +91,8 @@ async def test_product_wiki_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # 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 index 14cc774609dc..c76c3b6aad90 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_product_wikis_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-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 index 882b2a33d53f..5eea6965459e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_product_wikis_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", product_id="str", - api_version="2024-05-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 index f7552345916f..1d6914bd1adc 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_quota_by_counter_keys_list_by_service(self, resource_group): resource_group_name=resource_group.name, service_name="str", quota_counter_key="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -38,8 +37,7 @@ def test_quota_by_counter_keys_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", quota_counter_key="str", - parameters={"callsCount": 0, "kbTransferred": 0.0}, - api_version="2024-05-01", + parameters={"properties": {"callsCount": 0, "kbTransferred": 0.0}}, ) # 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 index 9e338785636a..555c1bd317d0 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_quota_by_counter_keys_list_by_service(self, resource_group): resource_group_name=resource_group.name, service_name="str", quota_counter_key="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -39,8 +38,7 @@ async def test_quota_by_counter_keys_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", quota_counter_key="str", - parameters={"callsCount": 0, "kbTransferred": 0.0}, - api_version="2024-05-01", + parameters={"properties": {"callsCount": 0, "kbTransferred": 0.0}}, ) # 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 index 047ef69f1d0e..9c8e4fec5a7a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_quota_by_period_keys_get(self, resource_group): service_name="str", quota_counter_key="str", quota_period_key="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -40,8 +39,7 @@ def test_quota_by_period_keys_update(self, resource_group): service_name="str", quota_counter_key="str", quota_period_key="str", - parameters={"callsCount": 0, "kbTransferred": 0.0}, - api_version="2024-05-01", + parameters={"properties": {"callsCount": 0, "kbTransferred": 0.0}}, ) # 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 index a4d567cc8e4f..5e94845cac58 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_quota_by_period_keys_get(self, resource_group): service_name="str", quota_counter_key="str", quota_period_key="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -41,8 +40,7 @@ async def test_quota_by_period_keys_update(self, resource_group): service_name="str", quota_counter_key="str", quota_period_key="str", - parameters={"callsCount": 0, "kbTransferred": 0.0}, - api_version="2024-05-01", + parameters={"properties": {"callsCount": 0, "kbTransferred": 0.0}}, ) # 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 index 7a49f0564a3f..da1308c178a6 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_region_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-05-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 index 9aa9f5b8949b..e253a2773325 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_region_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-05-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 index 7781a9124853..75e8d665459d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_reports_list_by_api(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -38,7 +37,6 @@ def test_reports_list_by_user(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -51,7 +49,6 @@ def test_reports_list_by_operation(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -64,7 +61,6 @@ def test_reports_list_by_product(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -77,7 +73,6 @@ def test_reports_list_by_geo(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -90,7 +85,6 @@ def test_reports_list_by_subscription(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -104,7 +98,6 @@ def test_reports_list_by_time(self, resource_group): service_name="str", filter="str", interval="1 day, 0:00:00", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -117,7 +110,6 @@ def test_reports_list_by_request(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-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 index fbd5946babdf..faa6460d2cd8 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_reports_list_by_api(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -39,7 +38,6 @@ async def test_reports_list_by_user(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -52,7 +50,6 @@ async def test_reports_list_by_operation(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -65,7 +62,6 @@ async def test_reports_list_by_product(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -78,7 +74,6 @@ async def test_reports_list_by_geo(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -91,7 +86,6 @@ async def test_reports_list_by_subscription(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -105,7 +99,6 @@ async def test_reports_list_by_time(self, resource_group): service_name="str", filter="str", interval="1 day, 0:00:00", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -118,7 +111,6 @@ async def test_reports_list_by_request(self, resource_group): resource_group_name=resource_group.name, service_name="str", filter="str", - api_version="2024-05-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 index e22f66648b46..9224b645cc4e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,11 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sign_in_settings_get_entity_tag(self, resource_group): - response = self.client.sign_in_settings.get_entity_tag( + def test_sign_in_settings_get(self, resource_group): + response = self.client.sign_in_settings.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -32,11 +31,10 @@ def test_sign_in_settings_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sign_in_settings_get(self, resource_group): - response = self.client.sign_in_settings.get( + def test_sign_in_settings_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-05-01", ) # please add some check logic here by yourself @@ -44,13 +42,24 @@ def test_sign_in_settings_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sign_in_settings_update(self, resource_group): - response = self.client.sign_in_settings.update( + def test_sign_in_settings_create_or_update(self, resource_group): + response = self.client.sign_in_settings.create_or_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-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"enabled": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -58,12 +67,26 @@ def test_sign_in_settings_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sign_in_settings_create_or_update(self, resource_group): - response = self.client.sign_in_settings.create_or_update( + def test_sign_in_settings_update(self, resource_group): + response = self.client.sign_in_settings.update( resource_group_name=resource_group.name, service_name="str", - parameters={"enabled": bool, "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"enabled": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # 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 index ad055b60b6b9..0296c2ee9de3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,11 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sign_in_settings_get_entity_tag(self, resource_group): - response = await self.client.sign_in_settings.get_entity_tag( + async def test_sign_in_settings_get(self, resource_group): + response = await self.client.sign_in_settings.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -33,11 +32,10 @@ async def test_sign_in_settings_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sign_in_settings_get(self, resource_group): - response = await self.client.sign_in_settings.get( + async def test_sign_in_settings_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-05-01", ) # please add some check logic here by yourself @@ -45,13 +43,24 @@ async def test_sign_in_settings_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sign_in_settings_update(self, resource_group): - response = await self.client.sign_in_settings.update( + async def test_sign_in_settings_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", - if_match="str", - parameters={"enabled": bool, "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"enabled": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -59,12 +68,26 @@ async def test_sign_in_settings_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sign_in_settings_create_or_update(self, resource_group): - response = await self.client.sign_in_settings.create_or_update( + async def test_sign_in_settings_update(self, resource_group): + response = await self.client.sign_in_settings.update( resource_group_name=resource_group.name, service_name="str", - parameters={"enabled": bool, "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"enabled": bool}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # 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 index eb6043350608..a3d4e106f5c6 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,11 +20,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sign_up_settings_get_entity_tag(self, resource_group): - response = self.client.sign_up_settings.get_entity_tag( + def test_sign_up_settings_get(self, resource_group): + response = self.client.sign_up_settings.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -32,11 +31,10 @@ def test_sign_up_settings_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sign_up_settings_get(self, resource_group): - response = self.client.sign_up_settings.get( + def test_sign_up_settings_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-05-01", ) # please add some check logic here by yourself @@ -44,19 +42,27 @@ def test_sign_up_settings_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sign_up_settings_update(self, resource_group): - response = self.client.sign_up_settings.update( + def test_sign_up_settings_create_or_update(self, resource_group): + response = self.client.sign_up_settings.create_or_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"}, + "properties": { + "enabled": bool, + "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -64,18 +70,29 @@ def test_sign_up_settings_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_sign_up_settings_create_or_update(self, resource_group): - response = self.client.sign_up_settings.create_or_update( + def test_sign_up_settings_update(self, resource_group): + response = self.client.sign_up_settings.update( resource_group_name=resource_group.name, service_name="str", parameters={ - "enabled": bool, "id": "str", "name": "str", - "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + "properties": { + "enabled": bool, + "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # 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 index cafcd126a9fd..aac54b295f55 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,11 +21,10 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sign_up_settings_get_entity_tag(self, resource_group): - response = await self.client.sign_up_settings.get_entity_tag( + async def test_sign_up_settings_get(self, resource_group): + response = await self.client.sign_up_settings.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -33,11 +32,10 @@ async def test_sign_up_settings_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sign_up_settings_get(self, resource_group): - response = await self.client.sign_up_settings.get( + async def test_sign_up_settings_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-05-01", ) # please add some check logic here by yourself @@ -45,19 +43,27 @@ async def test_sign_up_settings_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sign_up_settings_update(self, resource_group): - response = await self.client.sign_up_settings.update( + async def test_sign_up_settings_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", - if_match="str", parameters={ - "enabled": bool, "id": "str", "name": "str", - "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + "properties": { + "enabled": bool, + "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -65,18 +71,29 @@ async def test_sign_up_settings_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_sign_up_settings_create_or_update(self, resource_group): - response = await self.client.sign_up_settings.create_or_update( + async def test_sign_up_settings_update(self, resource_group): + response = await self.client.sign_up_settings.update( resource_group_name=resource_group.name, service_name="str", parameters={ - "enabled": bool, "id": "str", "name": "str", - "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + "properties": { + "enabled": bool, + "termsOfService": {"consentRequired": bool, "enabled": bool, "text": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # 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 index 22465db60402..38f853e961f3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_subscription_list(self, resource_group): - response = self.client.subscription.list( - resource_group_name=resource_group.name, - service_name="str", - api_version="2024-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_subscription_get_entity_tag(self, resource_group): - response = self.client.subscription.get_entity_tag( + def test_subscription_get(self, resource_group): + response = self.client.subscription.get( resource_group_name=resource_group.name, service_name="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_subscription_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_subscription_get(self, resource_group): - response = self.client.subscription.get( + def test_subscription_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-05-01", ) # please add some check logic here by yourself @@ -64,15 +50,16 @@ def test_subscription_create_or_update(self, resource_group): service_name="str", sid="str", parameters={ - "allowTracing": bool, - "displayName": "str", - "ownerId": "str", - "primaryKey": "str", - "scope": "str", - "secondaryKey": "str", - "state": "str", + "properties": { + "displayName": "str", + "scope": "str", + "allowTracing": bool, + "ownerId": "str", + "primaryKey": "str", + "secondaryKey": "str", + "state": "str", + } }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -85,19 +72,21 @@ def test_subscription_update(self, resource_group): 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", + "properties": { + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -110,13 +99,24 @@ def test_subscription_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", sid="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_subscription_list(self, resource_group): + response = self.client.subscription.list( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_subscription_regenerate_primary_key(self, resource_group): @@ -124,7 +124,6 @@ def test_subscription_regenerate_primary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -137,7 +136,6 @@ def test_subscription_regenerate_secondary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -150,7 +148,6 @@ def test_subscription_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", sid="str", - api_version="2024-05-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 index 0f9252121f3e..7fb071b0f72d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_subscription_list(self, resource_group): - response = self.client.subscription.list( - resource_group_name=resource_group.name, - service_name="str", - api_version="2024-05-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_subscription_get_entity_tag(self, resource_group): - response = await self.client.subscription.get_entity_tag( + async def test_subscription_get(self, resource_group): + response = await self.client.subscription.get( resource_group_name=resource_group.name, service_name="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_subscription_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_subscription_get(self, resource_group): - response = await self.client.subscription.get( + async def test_subscription_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-05-01", ) # please add some check logic here by yourself @@ -65,15 +51,16 @@ async def test_subscription_create_or_update(self, resource_group): service_name="str", sid="str", parameters={ - "allowTracing": bool, - "displayName": "str", - "ownerId": "str", - "primaryKey": "str", - "scope": "str", - "secondaryKey": "str", - "state": "str", + "properties": { + "displayName": "str", + "scope": "str", + "allowTracing": bool, + "ownerId": "str", + "primaryKey": "str", + "secondaryKey": "str", + "state": "str", + } }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -86,19 +73,21 @@ async def test_subscription_update(self, resource_group): 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", + "properties": { + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -111,13 +100,24 @@ async def test_subscription_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", sid="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_subscription_list(self, resource_group): + response = self.client.subscription.list( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_subscription_regenerate_primary_key(self, resource_group): @@ -125,7 +125,6 @@ async def test_subscription_regenerate_primary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -138,7 +137,6 @@ async def test_subscription_regenerate_secondary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -151,7 +149,6 @@ async def test_subscription_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", sid="str", - api_version="2024-05-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 index f99c6ea711e5..370e41b5a4aa 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_api_link_list_by_product(self, resource_group): - response = self.client.tag_api_link.list_by_product( + def test_tag_api_link_get(self, resource_group): + response = self.client.tag_api_link.get( resource_group_name=resource_group.name, service_name="str", tag_id="str", - api_version="2024-05-01", + api_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_api_link_get(self, resource_group): - response = self.client.tag_api_link.get( + def test_tag_api_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"apiId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -47,14 +60,12 @@ def test_tag_api_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_api_link_create_or_update(self, resource_group): - response = self.client.tag_api_link.create_or_update( + def test_tag_api_link_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", - parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -62,14 +73,12 @@ def test_tag_api_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_api_link_delete(self, resource_group): - response = self.client.tag_api_link.delete( + def test_tag_api_link_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_link_id="str", - api_version="2024-05-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_api_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_api_link_operations_async.py index a91aa713ee40..347c8c7acd1e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_api_link_list_by_product(self, resource_group): - response = self.client.tag_api_link.list_by_product( + async def test_tag_api_link_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_version="2024-05-01", + api_link_id="str", ) - 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_tag_api_link_get(self, resource_group): - response = await self.client.tag_api_link.get( + async def test_tag_api_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"apiId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -48,14 +61,12 @@ async def test_tag_api_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_api_link_create_or_update(self, resource_group): - response = await self.client.tag_api_link.create_or_update( + async def test_tag_api_link_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", - parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -63,14 +74,12 @@ async def test_tag_api_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_api_link_delete(self, resource_group): - response = await self.client.tag_api_link.delete( + async def test_tag_api_link_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_link_id="str", - api_version="2024-05-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_tag_operation_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations.py index 4acf5d15353d..b6524e8d2499 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_operation_link_list_by_product(self, resource_group): - response = self.client.tag_operation_link.list_by_product( + def test_tag_operation_link_get(self, resource_group): + response = self.client.tag_operation_link.get( resource_group_name=resource_group.name, service_name="str", tag_id="str", - api_version="2024-05-01", + operation_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_operation_link_get(self, resource_group): - response = self.client.tag_operation_link.get( + def test_tag_operation_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"operationId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -47,14 +60,12 @@ def test_tag_operation_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_operation_link_create_or_update(self, resource_group): - response = self.client.tag_operation_link.create_or_update( + def test_tag_operation_link_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", - parameters={"id": "str", "name": "str", "operationId": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -62,14 +73,12 @@ def test_tag_operation_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_operation_link_delete(self, resource_group): - response = self.client.tag_operation_link.delete( + def test_tag_operation_link_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", - operation_link_id="str", - api_version="2024-05-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_operation_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operation_link_operations_async.py index 13929d410148..f73214ec8924 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_operation_link_list_by_product(self, resource_group): - response = self.client.tag_operation_link.list_by_product( + async def test_tag_operation_link_get(self, resource_group): + response = await self.client.tag_operation_link.get( resource_group_name=resource_group.name, service_name="str", tag_id="str", - api_version="2024-05-01", + operation_link_id="str", ) - 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_tag_operation_link_get(self, resource_group): - response = await self.client.tag_operation_link.get( + async def test_tag_operation_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"operationId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -48,14 +61,12 @@ async def test_tag_operation_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_operation_link_create_or_update(self, resource_group): - response = await self.client.tag_operation_link.create_or_update( + async def test_tag_operation_link_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", - parameters={"id": "str", "name": "str", "operationId": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -63,14 +74,12 @@ async def test_tag_operation_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_operation_link_delete(self, resource_group): - response = await self.client.tag_operation_link.delete( + async def test_tag_operation_link_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", - operation_link_id="str", - api_version="2024-05-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_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations.py index 1def220d6b68..4bfb1ea2b46d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_tag_get_entity_state_by_operation(self, resource_group): - response = self.client.tag.get_entity_state_by_operation( + def test_tag_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", - operation_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -49,14 +33,12 @@ def test_tag_get_entity_state_by_operation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_get_by_operation(self, resource_group): - response = self.client.tag.get_by_operation( + def test_tag_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", - operation_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -64,14 +46,12 @@ def test_tag_get_by_operation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_assign_to_operation(self, resource_group): - response = self.client.tag.assign_to_operation( + def test_tag_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", - operation_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -79,14 +59,12 @@ def test_tag_assign_to_operation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_detach_from_operation(self, resource_group): - response = self.client.tag.detach_from_operation( + def test_tag_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", - operation_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -99,7 +77,6 @@ def test_tag_list_by_api(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -107,13 +84,13 @@ def test_tag_list_by_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_get_entity_state_by_api(self, resource_group): - response = self.client.tag.get_entity_state_by_api( + def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -121,13 +98,13 @@ def test_tag_get_entity_state_by_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_get_by_api(self, resource_group): - response = self.client.tag.get_by_api( + def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -135,13 +112,13 @@ def test_tag_get_by_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_assign_to_api(self, resource_group): - response = self.client.tag.assign_to_api( + def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -149,13 +126,13 @@ def test_tag_assign_to_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_detach_from_api(self, resource_group): - response = self.client.tag.detach_from_api( + def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -163,12 +140,12 @@ def test_tag_detach_from_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_list_by_product(self, resource_group): - response = self.client.tag.list_by_product( + def test_tag_list_by_operation(self, resource_group): + response = self.client.tag.list_by_operation( resource_group_name=resource_group.name, service_name="str", - product_id="str", - api_version="2024-05-01", + api_id="str", + operation_id="str", ) result = [r for r in response] # please add some check logic here by yourself @@ -176,13 +153,12 @@ def test_tag_list_by_product(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_get_entity_state_by_product(self, resource_group): - response = self.client.tag.get_entity_state_by_product( + def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -190,13 +166,12 @@ def test_tag_get_entity_state_by_product(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_get_by_product(self, resource_group): - response = self.client.tag.get_by_product( + def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -210,7 +185,6 @@ def test_tag_assign_to_product(self, resource_group): service_name="str", product_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -224,7 +198,6 @@ def test_tag_detach_from_product(self, resource_group): service_name="str", product_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -232,11 +205,11 @@ def test_tag_detach_from_product(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_list_by_service(self, resource_group): - response = self.client.tag.list_by_service( + def test_tag_list_by_product(self, resource_group): + response = self.client.tag.list_by_product( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + product_id="str", ) result = [r for r in response] # please add some check logic here by yourself @@ -244,12 +217,11 @@ def test_tag_list_by_service(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_get_entity_state(self, resource_group): - response = self.client.tag.get_entity_state( + def test_tag_get(self, resource_group): + response = self.client.tag.get( resource_group_name=resource_group.name, service_name="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -257,12 +229,11 @@ def test_tag_get_entity_state(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_get(self, resource_group): - response = self.client.tag.get( + def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -275,8 +246,7 @@ def test_tag_create_or_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", tag_id="str", - parameters={"displayName": "str"}, - api_version="2024-05-01", + parameters={"properties": {"displayName": "str"}}, ) # please add some check logic here by yourself @@ -289,9 +259,9 @@ def test_tag_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", tag_id="str", - if_match="str", - parameters={"displayName": "str"}, - api_version="2024-05-01", + parameters={"properties": {"displayName": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -304,9 +274,20 @@ def test_tag_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", tag_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_tag_list_by_service(self, resource_group): + response = self.client.tag.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_operations_async.py index 0b37ab4f580a..de6fcf547c9f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_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-05-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_tag_get_entity_state_by_operation(self, resource_group): - response = await self.client.tag.get_entity_state_by_operation( + async def test_tag_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", - operation_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -50,14 +34,12 @@ async def test_tag_get_entity_state_by_operation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_get_by_operation(self, resource_group): - response = await self.client.tag.get_by_operation( + async def test_tag_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", - operation_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -65,14 +47,12 @@ async def test_tag_get_by_operation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_assign_to_operation(self, resource_group): - response = await self.client.tag.assign_to_operation( + async def test_tag_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", - operation_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -80,14 +60,12 @@ async def test_tag_assign_to_operation(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_detach_from_operation(self, resource_group): - response = await self.client.tag.detach_from_operation( + async def test_tag_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", - operation_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -100,7 +78,6 @@ async def test_tag_list_by_api(self, resource_group): resource_group_name=resource_group.name, service_name="str", api_id="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -108,13 +85,13 @@ async def test_tag_list_by_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_get_entity_state_by_api(self, resource_group): - response = await self.client.tag.get_entity_state_by_api( + async def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -122,13 +99,13 @@ async def test_tag_get_entity_state_by_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_get_by_api(self, resource_group): - response = await self.client.tag.get_by_api( + async def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -136,13 +113,13 @@ async def test_tag_get_by_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_assign_to_api(self, resource_group): - response = await self.client.tag.assign_to_api( + async def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -150,13 +127,13 @@ async def test_tag_assign_to_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_detach_from_api(self, resource_group): - response = await self.client.tag.detach_from_api( + async def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -164,12 +141,12 @@ async def test_tag_detach_from_api(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_list_by_product(self, resource_group): - response = self.client.tag.list_by_product( + async def test_tag_list_by_operation(self, resource_group): + response = self.client.tag.list_by_operation( resource_group_name=resource_group.name, service_name="str", - product_id="str", - api_version="2024-05-01", + api_id="str", + operation_id="str", ) result = [r async for r in response] # please add some check logic here by yourself @@ -177,13 +154,12 @@ async def test_tag_list_by_product(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_get_entity_state_by_product(self, resource_group): - response = await self.client.tag.get_entity_state_by_product( + async def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -191,13 +167,12 @@ async def test_tag_get_entity_state_by_product(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_get_by_product(self, resource_group): - response = await self.client.tag.get_by_product( + async def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -211,7 +186,6 @@ async def test_tag_assign_to_product(self, resource_group): service_name="str", product_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -225,7 +199,6 @@ async def test_tag_detach_from_product(self, resource_group): service_name="str", product_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -233,11 +206,11 @@ async def test_tag_detach_from_product(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_list_by_service(self, resource_group): - response = self.client.tag.list_by_service( + async def test_tag_list_by_product(self, resource_group): + response = self.client.tag.list_by_product( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + product_id="str", ) result = [r async for r in response] # please add some check logic here by yourself @@ -245,12 +218,11 @@ async def test_tag_list_by_service(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_get_entity_state(self, resource_group): - response = await self.client.tag.get_entity_state( + async def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -258,12 +230,11 @@ async def test_tag_get_entity_state(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_get(self, resource_group): - response = await self.client.tag.get( + async def test_tag_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-05-01", ) # please add some check logic here by yourself @@ -276,8 +247,7 @@ async def test_tag_create_or_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", tag_id="str", - parameters={"displayName": "str"}, - api_version="2024-05-01", + parameters={"properties": {"displayName": "str"}}, ) # please add some check logic here by yourself @@ -290,9 +260,9 @@ async def test_tag_update(self, resource_group): resource_group_name=resource_group.name, service_name="str", tag_id="str", - if_match="str", - parameters={"displayName": "str"}, - api_version="2024-05-01", + parameters={"properties": {"displayName": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -305,9 +275,20 @@ async def test_tag_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", tag_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_tag_list_by_service(self, resource_group): + response = self.client.tag.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations.py index c5edc3e8742d..ac77091200d2 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_product_link_list_by_product(self, resource_group): - response = self.client.tag_product_link.list_by_product( + def test_tag_product_link_get(self, resource_group): + response = self.client.tag_product_link.get( resource_group_name=resource_group.name, service_name="str", tag_id="str", - api_version="2024-05-01", + product_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_product_link_get(self, resource_group): - response = self.client.tag_product_link.get( + def test_tag_product_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"productId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -47,14 +60,12 @@ def test_tag_product_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_product_link_create_or_update(self, resource_group): - response = self.client.tag_product_link.create_or_update( + def test_tag_product_link_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", - parameters={"id": "str", "name": "str", "productId": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -62,14 +73,12 @@ def test_tag_product_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tag_product_link_delete(self, resource_group): - response = self.client.tag_product_link.delete( + def test_tag_product_link_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", - product_link_id="str", - api_version="2024-05-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_product_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_product_link_operations_async.py index 2db65b97734b..527a69fc6202 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,39 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_product_link_list_by_product(self, resource_group): - response = self.client.tag_product_link.list_by_product( + async def test_tag_product_link_get(self, resource_group): + response = await self.client.tag_product_link.get( resource_group_name=resource_group.name, service_name="str", tag_id="str", - api_version="2024-05-01", + product_link_id="str", ) - 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_tag_product_link_get(self, resource_group): - response = await self.client.tag_product_link.get( + async def test_tag_product_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"productId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -48,14 +61,12 @@ async def test_tag_product_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_product_link_create_or_update(self, resource_group): - response = await self.client.tag_product_link.create_or_update( + async def test_tag_product_link_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", - parameters={"id": "str", "name": "str", "productId": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -63,14 +74,12 @@ async def test_tag_product_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tag_product_link_delete(self, resource_group): - response = await self.client.tag_product_link.delete( + async def test_tag_product_link_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", - product_link_id="str", - api_version="2024-05-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_tag_resource_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tag_resource_operations.py index c55240dd0e62..89194f969049 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,6 @@ def test_tag_resource_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-05-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 index f3e80bbe470c..c69bd33dd90d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ async def test_tag_resource_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-05-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 index 2c57913ac984..a12358d4faad 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_tenant_access_git_regenerate_primary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -38,7 +37,6 @@ def test_tenant_access_git_regenerate_secondary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-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 index bb5e73656880..2e801dc47bda 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_tenant_access_git_regenerate_primary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -39,7 +38,6 @@ async def test_tenant_access_git_regenerate_secondary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-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 index 7b80daa81245..d71646747ea1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tenant_access_list_by_service(self, resource_group): - response = self.client.tenant_access.list_by_service( + def test_tenant_access_get(self, resource_group): + response = self.client.tenant_access.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + access_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -37,7 +37,6 @@ def test_tenant_access_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +44,16 @@ def test_tenant_access_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tenant_access_get(self, resource_group): - response = self.client.tenant_access.get( + def test_tenant_access_create(self, resource_group): + response = self.client.tenant_access.create( resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", + parameters={ + "properties": {"enabled": bool, "primaryKey": "str", "principalId": "str", "secondaryKey": "str"} + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -58,14 +61,14 @@ def test_tenant_access_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tenant_access_create(self, resource_group): - response = self.client.tenant_access.create( + def test_tenant_access_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, "primaryKey": "str", "principalId": "str", "secondaryKey": "str"}, - api_version="2024-05-01", + parameters={"properties": {"enabled": bool}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -73,16 +76,12 @@ def test_tenant_access_create(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tenant_access_update(self, resource_group): - response = self.client.tenant_access.update( + def test_tenant_access_list_by_service(self, resource_group): + response = self.client.tenant_access.list_by_service( resource_group_name=resource_group.name, service_name="str", - access_name="str", - if_match="str", - parameters={"enabled": bool}, - api_version="2024-05-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -93,7 +92,6 @@ def test_tenant_access_regenerate_primary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -106,7 +104,6 @@ def test_tenant_access_regenerate_secondary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -119,7 +116,6 @@ def test_tenant_access_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-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 index e9baa75e972c..7091cf225ec7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tenant_access_list_by_service(self, resource_group): - response = self.client.tenant_access.list_by_service( + async def test_tenant_access_get(self, resource_group): + response = await self.client.tenant_access.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + access_name="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -38,7 +38,6 @@ async def test_tenant_access_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,12 +45,16 @@ async def test_tenant_access_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tenant_access_get(self, resource_group): - response = await self.client.tenant_access.get( + async def test_tenant_access_create(self, resource_group): + response = await self.client.tenant_access.create( resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", + parameters={ + "properties": {"enabled": bool, "primaryKey": "str", "principalId": "str", "secondaryKey": "str"} + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -59,14 +62,14 @@ async def test_tenant_access_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tenant_access_create(self, resource_group): - response = await self.client.tenant_access.create( + async def test_tenant_access_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, "primaryKey": "str", "principalId": "str", "secondaryKey": "str"}, - api_version="2024-05-01", + parameters={"properties": {"enabled": bool}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -74,16 +77,12 @@ async def test_tenant_access_create(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tenant_access_update(self, resource_group): - response = await self.client.tenant_access.update( + async def test_tenant_access_list_by_service(self, resource_group): + response = self.client.tenant_access.list_by_service( resource_group_name=resource_group.name, service_name="str", - access_name="str", - if_match="str", - parameters={"enabled": bool}, - api_version="2024-05-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -94,7 +93,6 @@ async def test_tenant_access_regenerate_primary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -107,7 +105,6 @@ async def test_tenant_access_regenerate_secondary_key(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -120,7 +117,6 @@ async def test_tenant_access_list_secrets(self, resource_group): resource_group_name=resource_group.name, service_name="str", access_name="str", - api_version="2024-05-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 index 2040b66233e8..7ef9fa54c7f8 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,8 +25,7 @@ def test_tenant_configuration_begin_deploy(self, resource_group): resource_group_name=resource_group.name, service_name="str", configuration_name="str", - parameters={"branch": "str", "force": bool}, - api_version="2024-05-01", + parameters={"properties": {"branch": "str", "force": bool}}, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -39,8 +38,7 @@ def test_tenant_configuration_begin_save(self, resource_group): resource_group_name=resource_group.name, service_name="str", configuration_name="str", - parameters={"branch": "str", "force": bool}, - api_version="2024-05-01", + parameters={"properties": {"branch": "str", "force": bool}}, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -53,8 +51,7 @@ def test_tenant_configuration_begin_validate(self, resource_group): resource_group_name=resource_group.name, service_name="str", configuration_name="str", - parameters={"branch": "str", "force": bool}, - api_version="2024-05-01", + parameters={"properties": {"branch": "str", "force": bool}}, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -67,7 +64,6 @@ def test_tenant_configuration_get_sync_state(self, resource_group): resource_group_name=resource_group.name, service_name="str", configuration_name="str", - api_version="2024-05-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 index 634aa0562cc1..86aebbf6acf7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,8 +27,7 @@ async def test_tenant_configuration_begin_deploy(self, resource_group): resource_group_name=resource_group.name, service_name="str", configuration_name="str", - parameters={"branch": "str", "force": bool}, - api_version="2024-05-01", + parameters={"properties": {"branch": "str", "force": bool}}, ) ).result() # call '.result()' to poll until service return final result @@ -43,8 +42,7 @@ async def test_tenant_configuration_begin_save(self, resource_group): resource_group_name=resource_group.name, service_name="str", configuration_name="str", - parameters={"branch": "str", "force": bool}, - api_version="2024-05-01", + parameters={"properties": {"branch": "str", "force": bool}}, ) ).result() # call '.result()' to poll until service return final result @@ -59,8 +57,7 @@ async def test_tenant_configuration_begin_validate(self, resource_group): resource_group_name=resource_group.name, service_name="str", configuration_name="str", - parameters={"branch": "str", "force": bool}, - api_version="2024-05-01", + parameters={"properties": {"branch": "str", "force": bool}}, ) ).result() # call '.result()' to poll until service return final result @@ -74,7 +71,6 @@ async def test_tenant_configuration_get_sync_state(self, resource_group): resource_group_name=resource_group.name, service_name="str", configuration_name="str", - api_version="2024-05-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 index 1d0f76304b6d..520422d1a2d3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tenant_settings_list_by_service(self, resource_group): - response = self.client.tenant_settings.list_by_service( + def test_tenant_settings_get(self, resource_group): + response = self.client.tenant_settings.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + settings_type="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_tenant_settings_get(self, resource_group): - response = self.client.tenant_settings.get( + def test_tenant_settings_list_by_service(self, resource_group): + response = self.client.tenant_settings.list_by_service( resource_group_name=resource_group.name, service_name="str", - settings_type="str", - api_version="2024-05-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_tenant_settings_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_tenant_settings_operations_async.py index c6b67794d762..bacf93ce0d81 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,23 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_tenant_settings_list_by_service(self, resource_group): - response = self.client.tenant_settings.list_by_service( + async def test_tenant_settings_get(self, resource_group): + response = await self.client.tenant_settings.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + settings_type="str", ) - 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_tenant_settings_get(self, resource_group): - response = await self.client.tenant_settings.get( + async def test_tenant_settings_list_by_service(self, resource_group): + response = self.client.tenant_settings.list_by_service( resource_group_name=resource_group.name, service_name="str", - settings_type="str", - api_version="2024-05-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_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_confirmation_password_operations.py index fecf1cd6879a..a28ef0076416 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_user_confirmation_password_send(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-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 index 7e6df681a86a..929255fc1b48 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_user_confirmation_password_send(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-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 index 668da1620970..835a33b35b2e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_user_group_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-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 index e6c4687cc60e..ee682f005d59 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_user_group_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-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 index 0bce5d7b5de0..134c55cdc954 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,6 @@ def test_user_identities_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-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 index 43ac550f81d2..28ab59692cd3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ async def test_user_identities_list(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-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 index 6af885006330..55e28db2f7af 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,24 +20,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_user_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_user_get_entity_tag(self, resource_group): - response = self.client.user.get_entity_tag( + def test_user_get(self, resource_group): + response = self.client.user.get( resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +32,11 @@ def test_user_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_user_get(self, resource_group): - response = self.client.user.get( + def test_user_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-05-01", ) # please add some check logic here by yourself @@ -64,17 +50,18 @@ def test_user_create_or_update(self, resource_group): 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", + "properties": { + "email": "str", + "firstName": "str", + "lastName": "str", + "appType": "str", + "confirmation": "str", + "identities": [{"id": "str", "provider": "str"}], + "note": "str", + "password": "str", + "state": "str", + } }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -87,17 +74,19 @@ def test_user_update(self, resource_group): 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", + "properties": { + "email": "str", + "firstName": "str", + "identities": [{"id": "str", "provider": "str"}], + "lastName": "str", + "note": "str", + "password": "str", + "state": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -110,13 +99,24 @@ def test_user_begin_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ).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_user_list_by_service(self, resource_group): + response = self.client.user.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_user_generate_sso_url(self, resource_group): @@ -124,7 +124,6 @@ def test_user_generate_sso_url(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -137,8 +136,7 @@ def test_user_get_shared_access_token(self, resource_group): 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-05-01", + parameters={"properties": {"expiry": "2020-02-20 00:00:00", "keyType": "str"}}, ) # 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 index 2b730c6e6aaf..86f56eef2678 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,24 +21,11 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_user_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-05-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_user_get_entity_tag(self, resource_group): - response = await self.client.user.get_entity_tag( + async def test_user_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-05-01", ) # please add some check logic here by yourself @@ -46,12 +33,11 @@ async def test_user_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_user_get(self, resource_group): - response = await self.client.user.get( + async def test_user_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-05-01", ) # please add some check logic here by yourself @@ -65,17 +51,18 @@ async def test_user_create_or_update(self, resource_group): 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", + "properties": { + "email": "str", + "firstName": "str", + "lastName": "str", + "appType": "str", + "confirmation": "str", + "identities": [{"id": "str", "provider": "str"}], + "note": "str", + "password": "str", + "state": "str", + } }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -88,17 +75,19 @@ async def test_user_update(self, resource_group): 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", + "properties": { + "email": "str", + "firstName": "str", + "identities": [{"id": "str", "provider": "str"}], + "lastName": "str", + "note": "str", + "password": "str", + "state": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -112,14 +101,25 @@ async def test_user_begin_delete(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) ).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_user_list_by_service(self, resource_group): + response = self.client.user.list_by_service( + resource_group_name=resource_group.name, + service_name="str", + ) + 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_user_generate_sso_url(self, resource_group): @@ -127,7 +127,6 @@ async def test_user_generate_sso_url(self, resource_group): resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -140,8 +139,7 @@ async def test_user_get_shared_access_token(self, resource_group): 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-05-01", + parameters={"properties": {"expiry": "2020-02-20 00:00:00", "keyType": "str"}}, ) # 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 index 32b3920e1652..538d93896967 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,27 +20,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_user_subscription_list(self, resource_group): - response = self.client.user_subscription.list( + def test_user_subscription_get(self, resource_group): + response = self.client.user_subscription.get( resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-01", + sid="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_user_subscription_get(self, resource_group): - response = self.client.user_subscription.get( + def test_user_subscription_list(self, resource_group): + response = self.client.user_subscription.list( resource_group_name=resource_group.name, service_name="str", user_id="str", - sid="str", - api_version="2024-05-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_subscription_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_user_subscription_operations_async.py index 1d5158f5d5d1..506e29d4699a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,27 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_user_subscription_list(self, resource_group): - response = self.client.user_subscription.list( + async def test_user_subscription_get(self, resource_group): + response = await self.client.user_subscription.get( resource_group_name=resource_group.name, service_name="str", user_id="str", - api_version="2024-05-01", + sid="str", ) - 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_user_subscription_get(self, resource_group): - response = await self.client.user_subscription.get( + async def test_user_subscription_list(self, resource_group): + response = self.client.user_subscription.list( resource_group_name=resource_group.name, service_name="str", user_id="str", - sid="str", - api_version="2024-05-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_diagnostic_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations.py index ef615eaa5136..138a11167d3e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_diagnostic_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_api_diagnostic_get_entity_tag(self, resource_group): - response = self.client.workspace_api_diagnostic.get_entity_tag( + def test_workspace_api_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -49,14 +34,13 @@ def test_workspace_api_diagnostic_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_diagnostic_get(self, resource_group): - response = self.client.workspace_api_diagnostic.get( + def test_workspace_api_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -72,55 +56,69 @@ def test_workspace_api_diagnostic_create_or_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -135,57 +133,67 @@ def test_workspace_api_diagnostic_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -200,9 +208,22 @@ def test_workspace_api_diagnostic_delete(self, resource_group): workspace_id="str", api_id="str", diagnostic_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_api_diagnostic_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", + ) + 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_diagnostic_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_diagnostic_operations_async.py index 46ca240d446b..a824f8fec08f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_diagnostic_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-05-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_workspace_api_diagnostic_get_entity_tag(self, resource_group): - response = await self.client.workspace_api_diagnostic.get_entity_tag( + async def test_workspace_api_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -50,14 +35,13 @@ async def test_workspace_api_diagnostic_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_diagnostic_get(self, resource_group): - response = await self.client.workspace_api_diagnostic.get( + async def test_workspace_api_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -73,55 +57,69 @@ async def test_workspace_api_diagnostic_create_or_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -136,57 +134,67 @@ async def test_workspace_api_diagnostic_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -201,9 +209,22 @@ async def test_workspace_api_diagnostic_delete(self, resource_group): workspace_id="str", api_id="str", diagnostic_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_api_diagnostic_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", + ) + 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_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_export_operations.py index 3528d25308e0..ce2fba5d76f8 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -28,7 +28,6 @@ def test_workspace_api_export_get(self, resource_group): api_id="str", format="str", export="str", - api_version="2024-05-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 index b95f314d1d65..6f2a1e45040f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -29,7 +29,6 @@ async def test_workspace_api_export_get(self, resource_group): api_id="str", format="str", export="str", - api_version="2024-05-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 index def475abf244..8e7b827e342d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_operation_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_api_operation_get_entity_tag(self, resource_group): - response = self.client.workspace_api_operation.get_entity_tag( + def test_workspace_api_operation_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-05-01", ) # please add some check logic here by yourself @@ -49,14 +34,13 @@ def test_workspace_api_operation_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_operation_get(self, resource_group): - response = self.client.workspace_api_operation.get( + def test_workspace_api_operation_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-05-01", ) # please add some check logic here by yourself @@ -72,78 +56,15 @@ def test_workspace_api_operation_create_or_update(self, resource_group): api_id="str", operation_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", - "method": "str", "name": "str", - "policies": "str", - "request": { + "properties": { + "displayName": "str", + "method": "str", + "urlTemplate": "str", "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, + "policies": "str", + "request": { "description": "str", "headers": [ { @@ -160,6 +81,21 @@ def test_workspace_api_operation_create_or_update(self, resource_group): "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", @@ -190,86 +126,12 @@ def test_workspace_api_operation_create_or_update(self, resource_group): "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-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_api_operation_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": [ + }, + "responses": [ { - "name": "str", - "type": "str", - "defaultValue": "str", + "statusCode": 0, "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": [ + "headers": [ { "name": "str", "type": "str", @@ -289,14 +151,90 @@ def test_workspace_api_operation_update(self, resource_group): "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"], } ], }, - "responses": [ - { - "statusCode": 0, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_api_operation_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", + parameters={ + "properties": { + "description": "str", + "displayName": "str", + "method": "str", + "policies": "str", + "request": { "description": "str", "headers": [ { @@ -313,6 +251,21 @@ def test_workspace_api_operation_update(self, resource_group): "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", @@ -343,26 +296,88 @@ def test_workspace_api_operation_update(self, resource_group): "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", + }, + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -377,9 +392,22 @@ def test_workspace_api_operation_delete(self, resource_group): workspace_id="str", api_id="str", operation_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_api_operation_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", + ) + 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_operation_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_operations_async.py index a849dde7c416..4f477607fc4e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_operation_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-05-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_workspace_api_operation_get_entity_tag(self, resource_group): - response = await self.client.workspace_api_operation.get_entity_tag( + async def test_workspace_api_operation_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-05-01", ) # please add some check logic here by yourself @@ -50,14 +35,13 @@ async def test_workspace_api_operation_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_operation_get(self, resource_group): - response = await self.client.workspace_api_operation.get( + async def test_workspace_api_operation_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-05-01", ) # please add some check logic here by yourself @@ -73,78 +57,15 @@ async def test_workspace_api_operation_create_or_update(self, resource_group): api_id="str", operation_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", - "method": "str", "name": "str", - "policies": "str", - "request": { + "properties": { + "displayName": "str", + "method": "str", + "urlTemplate": "str", "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, + "policies": "str", + "request": { "description": "str", "headers": [ { @@ -161,6 +82,21 @@ async def test_workspace_api_operation_create_or_update(self, resource_group): "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", @@ -191,86 +127,12 @@ async def test_workspace_api_operation_create_or_update(self, resource_group): "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-05-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_workspace_api_operation_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": [ + }, + "responses": [ { - "name": "str", - "type": "str", - "defaultValue": "str", + "statusCode": 0, "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": [ + "headers": [ { "name": "str", "type": "str", @@ -290,14 +152,90 @@ async def test_workspace_api_operation_update(self, resource_group): "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"], } ], }, - "responses": [ - { - "statusCode": 0, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_api_operation_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", + parameters={ + "properties": { + "description": "str", + "displayName": "str", + "method": "str", + "policies": "str", + "request": { "description": "str", "headers": [ { @@ -314,6 +252,21 @@ async def test_workspace_api_operation_update(self, resource_group): "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", @@ -344,26 +297,88 @@ async def test_workspace_api_operation_update(self, resource_group): "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", + }, + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -378,9 +393,22 @@ async def test_workspace_api_operation_delete(self, resource_group): workspace_id="str", api_id="str", operation_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_api_operation_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", + ) + 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_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations.py index 66177796c58d..ab9ec6a90c02 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,16 +20,16 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_operation_policy_list_by_operation(self, resource_group): - response = self.client.workspace_api_operation_policy.list_by_operation( + def test_workspace_api_operation_policy_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", - api_version="2024-05-01", + policy_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -43,7 +43,6 @@ def test_workspace_api_operation_policy_get_entity_tag(self, resource_group): api_id="str", operation_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -51,15 +50,28 @@ def test_workspace_api_operation_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_operation_policy_get(self, resource_group): - response = self.client.workspace_api_operation_policy.get( + def test_workspace_api_operation_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -67,16 +79,16 @@ def test_workspace_api_operation_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_operation_policy_create_or_update(self, resource_group): - response = self.client.workspace_api_operation_policy.create_or_update( + def test_workspace_api_operation_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -84,17 +96,14 @@ def test_workspace_api_operation_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_operation_policy_delete(self, resource_group): - response = self.client.workspace_api_operation_policy.delete( + def test_workspace_api_operation_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_operation_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operation_policy_operations_async.py index 8eaa1eeed7f0..e81a832a18e7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,16 +21,16 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_operation_policy_list_by_operation(self, resource_group): - response = self.client.workspace_api_operation_policy.list_by_operation( + async def test_workspace_api_operation_policy_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", - api_version="2024-05-01", + policy_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -44,7 +44,6 @@ async def test_workspace_api_operation_policy_get_entity_tag(self, resource_grou api_id="str", operation_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -52,15 +51,28 @@ async def test_workspace_api_operation_policy_get_entity_tag(self, resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_operation_policy_get(self, resource_group): - response = await self.client.workspace_api_operation_policy.get( + async def test_workspace_api_operation_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -68,16 +80,16 @@ async def test_workspace_api_operation_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_operation_policy_create_or_update(self, resource_group): - response = await self.client.workspace_api_operation_policy.create_or_update( + async def test_workspace_api_operation_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -85,17 +97,14 @@ async def test_workspace_api_operation_policy_create_or_update(self, resource_gr @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_operation_policy_delete(self, resource_group): - response = await self.client.workspace_api_operation_policy.delete( + async def test_workspace_api_operation_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations.py index 561f506810b7..6fdac48637f8 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_api_get_entity_tag(self, resource_group): - response = self.client.workspace_api.get_entity_tag( + def test_workspace_api_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_workspace_api_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_get(self, resource_group): - response = self.client.workspace_api.get( + def test_workspace_api_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-05-01", ) # please add some check logic here by yourself @@ -68,47 +53,50 @@ def test_workspace_api_begin_create_or_update(self, resource_group): workspace_id="str", api_id="str", parameters={ - "apiRevision": "str", - "apiRevisionDescription": "str", - "apiType": "str", - "apiVersion": "str", - "apiVersionDescription": "str", - "apiVersionSet": { + "properties": { + "path": "str", + "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", - "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"}, + "displayName": "str", + "format": "str", + "isCurrent": bool, + "isOnline": bool, + "license": {"name": "str", "url": "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-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -122,34 +110,38 @@ def test_workspace_api_update(self, resource_group): 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", + "properties": { + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -163,9 +155,21 @@ def test_workspace_api_delete(self, resource_group): service_name="str", workspace_id="str", api_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_api_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", + ) + 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_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_operations_async.py index 3296863a2b61..d979f9962328 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_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-05-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_workspace_api_get_entity_tag(self, resource_group): - response = await self.client.workspace_api.get_entity_tag( + async def test_workspace_api_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_workspace_api_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_get(self, resource_group): - response = await self.client.workspace_api.get( + async def test_workspace_api_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-05-01", ) # please add some check logic here by yourself @@ -70,19 +55,70 @@ async def test_workspace_api_begin_create_or_update(self, resource_group): workspace_id="str", api_id="str", parameters={ + "properties": { + "path": "str", + "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"}, + "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"}, + } + }, + ) + ).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_workspace_api_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", + parameters={ + "properties": { "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"}, @@ -95,66 +131,35 @@ async def test_workspace_api_begin_create_or_update(self, resource_group): "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-05-01", - ) - ).result() # call '.result()' to poll until service return final result + } + }, + etag="str", + match_condition=~azure.core.MatchConditions, + ) # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_update(self, resource_group): - response = await self.client.workspace_api.update( + async def test_workspace_api_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", - 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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -162,15 +167,12 @@ async def test_workspace_api_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_delete(self, resource_group): - response = await self.client.workspace_api.delete( + async def test_workspace_api_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_id="str", - if_match="str", - api_version="2024-05-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_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations.py index 0eeb75f8ca9c..83b91844ac3e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,15 +20,15 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_policy_list_by_api(self, resource_group): - response = self.client.workspace_api_policy.list_by_api( + def test_workspace_api_policy_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", - api_version="2024-05-01", + policy_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -41,7 +41,6 @@ def test_workspace_api_policy_get_entity_tag(self, resource_group): workspace_id="str", api_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -49,14 +48,27 @@ def test_workspace_api_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_policy_get(self, resource_group): - response = self.client.workspace_api_policy.get( + def test_workspace_api_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -64,15 +76,15 @@ def test_workspace_api_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_policy_create_or_update(self, resource_group): - response = self.client.workspace_api_policy.create_or_update( + def test_workspace_api_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -80,16 +92,13 @@ def test_workspace_api_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_policy_delete(self, resource_group): - response = self.client.workspace_api_policy.delete( + def test_workspace_api_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_policy_operations_async.py index 5fa60009416f..a6ec2e5d0651 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,15 +21,15 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_policy_list_by_api(self, resource_group): - response = self.client.workspace_api_policy.list_by_api( + async def test_workspace_api_policy_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", - api_version="2024-05-01", + policy_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -42,7 +42,6 @@ async def test_workspace_api_policy_get_entity_tag(self, resource_group): workspace_id="str", api_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -50,14 +49,27 @@ async def test_workspace_api_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_policy_get(self, resource_group): - response = await self.client.workspace_api_policy.get( + async def test_workspace_api_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -65,15 +77,15 @@ async def test_workspace_api_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_policy_create_or_update(self, resource_group): - response = await self.client.workspace_api_policy.create_or_update( + async def test_workspace_api_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -81,16 +93,13 @@ async def test_workspace_api_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_policy_delete(self, resource_group): - response = await self.client.workspace_api_policy.delete( + async def test_workspace_api_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_release_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations.py index 769e3c63fb2d..15a6897e5c54 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_release_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_api_release_get_entity_tag(self, resource_group): - response = self.client.workspace_api_release.get_entity_tag( + def test_workspace_api_release_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-05-01", ) # please add some check logic here by yourself @@ -49,14 +34,13 @@ def test_workspace_api_release_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_release_get(self, resource_group): - response = self.client.workspace_api_release.get( + def test_workspace_api_release_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-05-01", ) # please add some check logic here by yourself @@ -72,15 +56,24 @@ def test_workspace_api_release_create_or_update(self, resource_group): api_id="str", release_id="str", parameters={ - "apiId": "str", - "createdDateTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "notes": "str", + "properties": { + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "notes": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -95,17 +88,27 @@ def test_workspace_api_release_update(self, resource_group): 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", + "properties": { + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "notes": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -120,9 +123,22 @@ def test_workspace_api_release_delete(self, resource_group): workspace_id="str", api_id="str", release_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_api_release_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", + ) + 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_release_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_release_operations_async.py index b318faff6ee5..fac0ebda9a30 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_release_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-05-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_workspace_api_release_get_entity_tag(self, resource_group): - response = await self.client.workspace_api_release.get_entity_tag( + async def test_workspace_api_release_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-05-01", ) # please add some check logic here by yourself @@ -50,14 +35,13 @@ async def test_workspace_api_release_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_release_get(self, resource_group): - response = await self.client.workspace_api_release.get( + async def test_workspace_api_release_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-05-01", ) # please add some check logic here by yourself @@ -73,15 +57,24 @@ async def test_workspace_api_release_create_or_update(self, resource_group): api_id="str", release_id="str", parameters={ - "apiId": "str", - "createdDateTime": "2020-02-20 00:00:00", "id": "str", "name": "str", - "notes": "str", + "properties": { + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "notes": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -96,17 +89,27 @@ async def test_workspace_api_release_update(self, resource_group): 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", + "properties": { + "apiId": "str", + "createdDateTime": "2020-02-20 00:00:00", + "notes": "str", + "updatedDateTime": "2020-02-20 00:00:00", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "updatedDateTime": "2020-02-20 00:00:00", }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -121,9 +124,22 @@ async def test_workspace_api_release_delete(self, resource_group): workspace_id="str", api_id="str", release_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_api_release_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", + ) + 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_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_revision_operations.py index a0814be521bb..20ee219614da 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_workspace_api_revision_list_by_service(self, resource_group): service_name="str", workspace_id="str", api_id="str", - api_version="2024-05-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 index 0c0a83fe7032..da267514810a 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_workspace_api_revision_list_by_service(self, resource_group): service_name="str", workspace_id="str", api_id="str", - api_version="2024-05-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 index dd534c94e7fd..ab7b48ee0744 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_schema_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_api_schema_get_entity_tag(self, resource_group): - response = self.client.workspace_api_schema.get_entity_tag( + def test_workspace_api_schema_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-05-01", ) # please add some check logic here by yourself @@ -49,14 +34,13 @@ def test_workspace_api_schema_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_schema_get(self, resource_group): - response = self.client.workspace_api_schema.get( + def test_workspace_api_schema_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-05-01", ) # please add some check logic here by yourself @@ -72,16 +56,23 @@ def test_workspace_api_schema_begin_create_or_update(self, resource_group): api_id="str", schema_id="str", parameters={ - "components": {}, - "contentType": "str", - "definitions": {}, "id": "str", "name": "str", - "provisioningState": "str", + "properties": { + "contentType": "str", + "document": {"components": {}, "definitions": {}, "value": "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", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -96,9 +87,22 @@ def test_workspace_api_schema_delete(self, resource_group): workspace_id="str", api_id="str", schema_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_api_schema_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", + ) + 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_schema_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_schema_operations_async.py index 3d419218eac2..71cb714eea83 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_schema_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-05-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_workspace_api_schema_get_entity_tag(self, resource_group): - response = await self.client.workspace_api_schema.get_entity_tag( + async def test_workspace_api_schema_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-05-01", ) # please add some check logic here by yourself @@ -50,14 +35,13 @@ async def test_workspace_api_schema_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_schema_get(self, resource_group): - response = await self.client.workspace_api_schema.get( + async def test_workspace_api_schema_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-05-01", ) # please add some check logic here by yourself @@ -74,16 +58,23 @@ async def test_workspace_api_schema_begin_create_or_update(self, resource_group) api_id="str", schema_id="str", parameters={ - "components": {}, - "contentType": "str", - "definitions": {}, "id": "str", "name": "str", - "provisioningState": "str", + "properties": { + "contentType": "str", + "document": {"components": {}, "definitions": {}, "value": "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", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -99,9 +90,22 @@ async def test_workspace_api_schema_delete(self, resource_group): workspace_id="str", api_id="str", schema_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_api_schema_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", + ) + 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_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations.py index ae5157bfae94..01ae34ce8a88 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_version_set_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_api_version_set_get_entity_tag(self, resource_group): - response = self.client.workspace_api_version_set.get_entity_tag( + def test_workspace_api_version_set_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_workspace_api_version_set_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_api_version_set_get(self, resource_group): - response = self.client.workspace_api_version_set.get( + def test_workspace_api_version_set_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-05-01", ) # please add some check logic here by yourself @@ -68,16 +53,25 @@ def test_workspace_api_version_set_create_or_update(self, resource_group): workspace_id="str", version_set_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", "name": "str", + "properties": { + "displayName": "str", + "versioningScheme": "str", + "description": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "versionHeaderName": "str", - "versionQueryName": "str", - "versioningScheme": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -91,15 +85,17 @@ def test_workspace_api_version_set_update(self, resource_group): service_name="str", workspace_id="str", version_set_id="str", - if_match="str", parameters={ - "description": "str", - "displayName": "str", - "versionHeaderName": "str", - "versionQueryName": "str", - "versioningScheme": "str", + "properties": { + "description": "str", + "displayName": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -113,9 +109,21 @@ def test_workspace_api_version_set_delete(self, resource_group): service_name="str", workspace_id="str", version_set_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_api_version_set_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", + ) + 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_version_set_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_api_version_set_operations_async.py index c843cf6c9d23..8b84035f21d1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_version_set_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-05-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_workspace_api_version_set_get_entity_tag(self, resource_group): - response = await self.client.workspace_api_version_set.get_entity_tag( + async def test_workspace_api_version_set_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_workspace_api_version_set_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_api_version_set_get(self, resource_group): - response = await self.client.workspace_api_version_set.get( + async def test_workspace_api_version_set_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-05-01", ) # please add some check logic here by yourself @@ -69,16 +54,25 @@ async def test_workspace_api_version_set_create_or_update(self, resource_group): workspace_id="str", version_set_id="str", parameters={ - "description": "str", - "displayName": "str", "id": "str", "name": "str", + "properties": { + "displayName": "str", + "versioningScheme": "str", + "description": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "versionHeaderName": "str", - "versionQueryName": "str", - "versioningScheme": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -92,15 +86,17 @@ async def test_workspace_api_version_set_update(self, resource_group): service_name="str", workspace_id="str", version_set_id="str", - if_match="str", parameters={ - "description": "str", - "displayName": "str", - "versionHeaderName": "str", - "versionQueryName": "str", - "versioningScheme": "str", + "properties": { + "description": "str", + "displayName": "str", + "versionHeaderName": "str", + "versionQueryName": "str", + "versioningScheme": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -114,9 +110,21 @@ async def test_workspace_api_version_set_delete(self, resource_group): service_name="str", workspace_id="str", version_set_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_api_version_set_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", + ) + 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_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations.py index abb7169aacd3..5a653910eff1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_backend_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_backend_get_entity_tag(self, resource_group): - response = self.client.workspace_backend.get_entity_tag( + def test_workspace_backend_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_workspace_backend_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_backend_get(self, resource_group): - response = self.client.workspace_backend.get( + def test_workspace_backend_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-05-01", ) # please add some check logic here by yourself @@ -68,52 +53,73 @@ def test_workspace_backend_create_or_update(self, resource_group): 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, + "azureRegion": "str", + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "failureResponse": {"statusCode": 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": { + "failureResponse": {"statusCode": 0}, + "services": [{"id": "str", "preferredCarbonEmission": "str", "priority": 0, "weight": 0}], + "sessionAffinity": {"sessionId": {"name": "str", "source": "str"}}, + }, + "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": { "serverCertificateThumbprints": ["str"], "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], - } + "validateCertificateChain": bool, + "validateCertificateName": bool, + }, + "type": "str", + "url": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -127,52 +133,65 @@ def test_workspace_backend_update(self, resource_group): 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, + "azureRegion": "str", + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "failureResponse": {"statusCode": 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": { + "failureResponse": {"statusCode": 0}, + "services": [{"id": "str", "preferredCarbonEmission": "str", "priority": 0, "weight": 0}], + "sessionAffinity": {"sessionId": {"name": "str", "source": "str"}}, + }, + "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": { "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", + "validateCertificateChain": bool, + "validateCertificateName": bool, + }, + "type": "str", + "url": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -186,9 +205,21 @@ def test_workspace_backend_delete(self, resource_group): service_name="str", workspace_id="str", backend_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_backend_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", + ) + 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_backend_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_backend_operations_async.py index 52c14e2a15e1..c783889bfd02 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_backend_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-05-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_workspace_backend_get_entity_tag(self, resource_group): - response = await self.client.workspace_backend.get_entity_tag( + async def test_workspace_backend_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_workspace_backend_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_backend_get(self, resource_group): - response = await self.client.workspace_backend.get( + async def test_workspace_backend_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-05-01", ) # please add some check logic here by yourself @@ -69,52 +54,73 @@ async def test_workspace_backend_create_or_update(self, resource_group): 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, + "azureRegion": "str", + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "failureResponse": {"statusCode": 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": { + "failureResponse": {"statusCode": 0}, + "services": [{"id": "str", "preferredCarbonEmission": "str", "priority": 0, "weight": 0}], + "sessionAffinity": {"sessionId": {"name": "str", "source": "str"}}, + }, + "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": { "serverCertificateThumbprints": ["str"], "serverX509Names": [{"issuerCertificateThumbprint": "str", "name": "str"}], - } + "validateCertificateChain": bool, + "validateCertificateName": bool, + }, + "type": "str", + "url": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -128,52 +134,65 @@ async def test_workspace_backend_update(self, resource_group): 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, + "azureRegion": "str", + "circuitBreaker": { + "rules": [ + { + "acceptRetryAfter": bool, + "failureCondition": { + "count": 0, + "errorReasons": ["str"], + "interval": "1 day, 0:00:00", + "percentage": 0, + "statusCodeRanges": [{"max": 0, "min": 0}], + }, + "failureResponse": {"statusCode": 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": { + "failureResponse": {"statusCode": 0}, + "services": [{"id": "str", "preferredCarbonEmission": "str", "priority": 0, "weight": 0}], + "sessionAffinity": {"sessionId": {"name": "str", "source": "str"}}, + }, + "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": { "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", + "validateCertificateChain": bool, + "validateCertificateName": bool, + }, + "type": "str", + "url": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -187,9 +206,21 @@ async def test_workspace_backend_delete(self, resource_group): service_name="str", workspace_id="str", backend_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_backend_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", + ) + 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_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_certificate_operations.py index 6d9c4df715aa..e8011d8dbc67 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_certificate_list_by_workspace(self, resource_group): - response = self.client.workspace_certificate.list_by_workspace( + def test_workspace_certificate_get(self, resource_group): + response = self.client.workspace_certificate.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + certificate_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -39,7 +39,6 @@ def test_workspace_certificate_get_entity_tag(self, resource_group): service_name="str", workspace_id="str", certificate_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,19 @@ def test_workspace_certificate_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_certificate_get(self, resource_group): - response = self.client.workspace_certificate.get( + def test_workspace_certificate_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", - api_version="2024-05-01", + parameters={ + "properties": { + "data": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "password": "str", + } + }, ) # please add some check logic here by yourself @@ -61,18 +66,14 @@ def test_workspace_certificate_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_certificate_create_or_update(self, resource_group): - response = self.client.workspace_certificate.create_or_update( + def test_workspace_certificate_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", - parameters={ - "data": "str", - "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, - "password": "str", - }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -80,16 +81,13 @@ def test_workspace_certificate_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_certificate_delete(self, resource_group): - response = self.client.workspace_certificate.delete( + def test_workspace_certificate_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", - certificate_id="str", - if_match="str", - api_version="2024-05-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -101,7 +99,6 @@ def test_workspace_certificate_refresh_secret(self, resource_group): service_name="str", workspace_id="str", certificate_id="str", - api_version="2024-05-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 index 155460b1fa63..380849c1c876 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_certificate_list_by_workspace(self, resource_group): - response = self.client.workspace_certificate.list_by_workspace( + async def test_workspace_certificate_get(self, resource_group): + response = await self.client.workspace_certificate.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + certificate_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +40,6 @@ async def test_workspace_certificate_get_entity_tag(self, resource_group): service_name="str", workspace_id="str", certificate_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,19 @@ async def test_workspace_certificate_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_certificate_get(self, resource_group): - response = await self.client.workspace_certificate.get( + async def test_workspace_certificate_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", - api_version="2024-05-01", + parameters={ + "properties": { + "data": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "password": "str", + } + }, ) # please add some check logic here by yourself @@ -62,18 +67,14 @@ async def test_workspace_certificate_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_certificate_create_or_update(self, resource_group): - response = await self.client.workspace_certificate.create_or_update( + async def test_workspace_certificate_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", - parameters={ - "data": "str", - "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, - "password": "str", - }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -81,16 +82,13 @@ async def test_workspace_certificate_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_certificate_delete(self, resource_group): - response = await self.client.workspace_certificate.delete( + async def test_workspace_certificate_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", - certificate_id="str", - if_match="str", - api_version="2024-05-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -102,7 +100,6 @@ async def test_workspace_certificate_refresh_secret(self, resource_group): service_name="str", workspace_id="str", certificate_id="str", - api_version="2024-05-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 index 1eeff8f62b47..f8ed25cc1bfd 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_diagnostic_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_diagnostic_get_entity_tag(self, resource_group): - response = self.client.workspace_diagnostic.get_entity_tag( + def test_workspace_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_workspace_diagnostic_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_diagnostic_get(self, resource_group): - response = self.client.workspace_diagnostic.get( + def test_workspace_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -68,55 +53,69 @@ def test_workspace_diagnostic_create_or_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -130,57 +129,67 @@ def test_workspace_diagnostic_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -194,9 +203,21 @@ def test_workspace_diagnostic_delete(self, resource_group): service_name="str", workspace_id="str", diagnostic_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_diagnostic_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", + ) + 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_diagnostic_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_diagnostic_operations_async.py index 3f276c516041..142f8c344e82 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_diagnostic_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-05-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_workspace_diagnostic_get_entity_tag(self, resource_group): - response = await self.client.workspace_diagnostic.get_entity_tag( + async def test_workspace_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_workspace_diagnostic_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_diagnostic_get(self, resource_group): - response = await self.client.workspace_diagnostic.get( + async def test_workspace_diagnostic_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-05-01", ) # please add some check logic here by yourself @@ -69,55 +54,69 @@ async def test_workspace_diagnostic_create_or_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "loggerId": "str", + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "largeLanguageModel": { + "logs": "str", + "requests": {"maxSizeInBytes": 0, "messages": "str"}, + "responses": {"maxSizeInBytes": 0, "messages": "str"}, + }, + "logClientIp": bool, + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", ) # please add some check logic here by yourself @@ -131,57 +130,67 @@ async def test_workspace_diagnostic_update(self, resource_group): 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"}], + "id": "str", + "name": "str", + "properties": { + "alwaysLog": "str", + "backend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, - }, - "frontend": { - "request": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "frontend": { + "request": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], - }, - "response": { - "body": {"bytes": 0}, - "dataMasking": { - "headers": [{"mode": "str", "value": "str"}], - "queryParams": [{"mode": "str", "value": "str"}], + "response": { + "body": {"bytes": 0}, + "dataMasking": { + "headers": [{"mode": "str", "value": "str"}], + "queryParams": [{"mode": "str", "value": "str"}], + }, + "headers": ["str"], }, - "headers": ["str"], }, + "httpCorrelationProtocol": "str", + "logClientIp": bool, + "loggerId": "str", + "metrics": bool, + "operationNameFormat": "str", + "sampling": {"percentage": 0.0, "samplingType": "str"}, + "verbosity": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -195,9 +204,21 @@ async def test_workspace_diagnostic_delete(self, resource_group): service_name="str", workspace_id="str", diagnostic_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_diagnostic_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", + ) + 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_global_schema_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations.py index d719385e27ac..ae09fcafa244 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_global_schema_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_global_schema_get_entity_tag(self, resource_group): - response = self.client.workspace_global_schema.get_entity_tag( + def test_workspace_global_schema_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_workspace_global_schema_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_global_schema_get(self, resource_group): - response = self.client.workspace_global_schema.get( + def test_workspace_global_schema_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-05-01", ) # please add some check logic here by yourself @@ -68,16 +53,25 @@ def test_workspace_global_schema_begin_create_or_update(self, resource_group): workspace_id="str", schema_id="str", parameters={ - "description": "str", - "document": {}, "id": "str", "name": "str", - "provisioningState": "str", - "schemaType": "str", + "properties": { + "schemaType": "str", + "description": "str", + "document": {}, + "provisioningState": "str", + "value": {}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "value": {}, }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -91,9 +85,21 @@ def test_workspace_global_schema_delete(self, resource_group): service_name="str", workspace_id="str", schema_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_global_schema_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", + ) + 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_global_schema_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_global_schema_operations_async.py index aed219cbeb88..52723fe3d953 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_global_schema_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-05-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_workspace_global_schema_get_entity_tag(self, resource_group): - response = await self.client.workspace_global_schema.get_entity_tag( + async def test_workspace_global_schema_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_workspace_global_schema_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_global_schema_get(self, resource_group): - response = await self.client.workspace_global_schema.get( + async def test_workspace_global_schema_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-05-01", ) # please add some check logic here by yourself @@ -70,16 +55,25 @@ async def test_workspace_global_schema_begin_create_or_update(self, resource_gro workspace_id="str", schema_id="str", parameters={ - "description": "str", - "document": {}, "id": "str", "name": "str", - "provisioningState": "str", - "schemaType": "str", + "properties": { + "schemaType": "str", + "description": "str", + "document": {}, + "provisioningState": "str", + "value": {}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "value": {}, }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -94,9 +88,21 @@ async def test_workspace_global_schema_delete(self, resource_group): service_name="str", workspace_id="str", schema_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_global_schema_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", + ) + 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_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations.py index 79baaa8a4b48..b20b63553075 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_group_list_by_service(self, resource_group): - response = self.client.workspace_group.list_by_service( + def test_workspace_group_get(self, resource_group): + response = self.client.workspace_group.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + group_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -39,7 +39,6 @@ def test_workspace_group_get_entity_tag(self, resource_group): service_name="str", workspace_id="str", group_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,13 @@ def test_workspace_group_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_group_get(self, resource_group): - response = self.client.workspace_group.get( + def test_workspace_group_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", - api_version="2024-05-01", + parameters={"properties": {"displayName": "str", "description": "str", "externalId": "str", "type": "str"}}, ) # please add some check logic here by yourself @@ -61,14 +60,15 @@ def test_workspace_group_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_group_create_or_update(self, resource_group): - response = self.client.workspace_group.create_or_update( + def test_workspace_group_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", - parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, - api_version="2024-05-01", + parameters={"properties": {"description": "str", "displayName": "str", "externalId": "str", "type": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -76,15 +76,14 @@ def test_workspace_group_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_group_update(self, resource_group): - response = self.client.workspace_group.update( + def test_workspace_group_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", - parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -92,15 +91,12 @@ def test_workspace_group_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_group_delete(self, resource_group): - response = self.client.workspace_group.delete( + def test_workspace_group_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", - group_id="str", - if_match="str", - api_version="2024-05-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_group_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_operations_async.py index c8ba2bf14a08..1108f376a576 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_group_list_by_service(self, resource_group): - response = self.client.workspace_group.list_by_service( + async def test_workspace_group_get(self, resource_group): + response = await self.client.workspace_group.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + group_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +40,6 @@ async def test_workspace_group_get_entity_tag(self, resource_group): service_name="str", workspace_id="str", group_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,13 @@ async def test_workspace_group_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_group_get(self, resource_group): - response = await self.client.workspace_group.get( + async def test_workspace_group_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", - api_version="2024-05-01", + parameters={"properties": {"displayName": "str", "description": "str", "externalId": "str", "type": "str"}}, ) # please add some check logic here by yourself @@ -62,14 +61,15 @@ async def test_workspace_group_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_group_create_or_update(self, resource_group): - response = await self.client.workspace_group.create_or_update( + async def test_workspace_group_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", - parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, - api_version="2024-05-01", + parameters={"properties": {"description": "str", "displayName": "str", "externalId": "str", "type": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -77,15 +77,14 @@ async def test_workspace_group_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_group_update(self, resource_group): - response = await self.client.workspace_group.update( + async def test_workspace_group_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", - parameters={"description": "str", "displayName": "str", "externalId": "str", "type": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -93,15 +92,12 @@ async def test_workspace_group_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_group_delete(self, resource_group): - response = await self.client.workspace_group.delete( + async def test_workspace_group_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", - group_id="str", - if_match="str", - api_version="2024-05-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_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_group_user_operations.py index 60ecd53cc804..b3058754a7bd 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_workspace_group_user_list(self, resource_group): service_name="str", workspace_id="str", group_id="str", - api_version="2024-05-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -41,7 +40,6 @@ def test_workspace_group_user_check_entity_exists(self, resource_group): workspace_id="str", group_id="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -56,7 +54,6 @@ def test_workspace_group_user_create(self, resource_group): workspace_id="str", group_id="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -71,7 +68,6 @@ def test_workspace_group_user_delete(self, resource_group): workspace_id="str", group_id="str", user_id="str", - api_version="2024-05-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 index c00f2ef62ac2..4e1793bc21bc 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_workspace_group_user_list(self, resource_group): service_name="str", workspace_id="str", group_id="str", - api_version="2024-05-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -42,7 +41,6 @@ async def test_workspace_group_user_check_entity_exists(self, resource_group): workspace_id="str", group_id="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -57,7 +55,6 @@ async def test_workspace_group_user_create(self, resource_group): workspace_id="str", group_id="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -72,7 +69,6 @@ async def test_workspace_group_user_delete(self, resource_group): workspace_id="str", group_id="str", user_id="str", - api_version="2024-05-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 index 9190fd02c087..3e3051a42aac 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_logger_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_logger_get_entity_tag(self, resource_group): - response = self.client.workspace_logger.get_entity_tag( + def test_workspace_logger_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_workspace_logger_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_logger_get(self, resource_group): - response = self.client.workspace_logger.get( + def test_workspace_logger_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-05-01", ) # please add some check logic here by yourself @@ -68,16 +53,25 @@ def test_workspace_logger_create_or_update(self, resource_group): workspace_id="str", logger_id="str", parameters={ - "credentials": {"str": "str"}, - "description": "str", "id": "str", - "isBuffered": bool, - "loggerType": "str", "name": "str", - "resourceId": "str", + "properties": { + "loggerType": "str", + "credentials": {"str": "str"}, + "description": "str", + "isBuffered": bool, + "resourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -91,9 +85,16 @@ def test_workspace_logger_update(self, resource_group): 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-05-01", + parameters={ + "properties": { + "credentials": {"str": "str"}, + "description": "str", + "isBuffered": bool, + "loggerType": "str", + } + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -107,9 +108,21 @@ def test_workspace_logger_delete(self, resource_group): service_name="str", workspace_id="str", logger_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_logger_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", + ) + 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_logger_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_logger_operations_async.py index ae7a384cdc50..709b387aee7f 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_logger_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-05-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_workspace_logger_get_entity_tag(self, resource_group): - response = await self.client.workspace_logger.get_entity_tag( + async def test_workspace_logger_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_workspace_logger_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_logger_get(self, resource_group): - response = await self.client.workspace_logger.get( + async def test_workspace_logger_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-05-01", ) # please add some check logic here by yourself @@ -69,16 +54,25 @@ async def test_workspace_logger_create_or_update(self, resource_group): workspace_id="str", logger_id="str", parameters={ - "credentials": {"str": "str"}, - "description": "str", "id": "str", - "isBuffered": bool, - "loggerType": "str", "name": "str", - "resourceId": "str", + "properties": { + "loggerType": "str", + "credentials": {"str": "str"}, + "description": "str", + "isBuffered": bool, + "resourceId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -92,9 +86,16 @@ async def test_workspace_logger_update(self, resource_group): 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-05-01", + parameters={ + "properties": { + "credentials": {"str": "str"}, + "description": "str", + "isBuffered": bool, + "loggerType": "str", + } + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -108,9 +109,21 @@ async def test_workspace_logger_delete(self, resource_group): service_name="str", workspace_id="str", logger_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_logger_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", + ) + 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_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_named_value_operations.py index d954cb6a235c..4f61803cce42 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_named_value_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_named_value_get_entity_tag(self, resource_group): - response = self.client.workspace_named_value.get_entity_tag( + def test_workspace_named_value_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_workspace_named_value_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_named_value_get(self, resource_group): - response = self.client.workspace_named_value.get( + def test_workspace_named_value_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-05-01", ) # please add some check logic here by yourself @@ -68,16 +53,25 @@ def test_workspace_named_value_begin_create_or_update(self, resource_group): workspace_id="str", named_value_id="str", parameters={ - "displayName": "str", "id": "str", - "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, "name": "str", - "secret": bool, - "tags": ["str"], + "properties": { + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -91,15 +85,17 @@ def test_workspace_named_value_begin_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -113,13 +109,25 @@ def test_workspace_named_value_delete(self, resource_group): service_name="str", workspace_id="str", named_value_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_named_value_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", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_workspace_named_value_list_value(self, resource_group): @@ -128,7 +136,6 @@ def test_workspace_named_value_list_value(self, resource_group): service_name="str", workspace_id="str", named_value_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -142,7 +149,6 @@ def test_workspace_named_value_begin_refresh_secret(self, resource_group): service_name="str", workspace_id="str", named_value_id="str", - api_version="2024-05-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 index 29077ed40ac6..8d8fdff3b9a5 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_named_value_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-05-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_workspace_named_value_get_entity_tag(self, resource_group): - response = await self.client.workspace_named_value.get_entity_tag( + async def test_workspace_named_value_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_workspace_named_value_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_named_value_get(self, resource_group): - response = await self.client.workspace_named_value.get( + async def test_workspace_named_value_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-05-01", ) # please add some check logic here by yourself @@ -70,16 +55,25 @@ async def test_workspace_named_value_begin_create_or_update(self, resource_group workspace_id="str", named_value_id="str", parameters={ - "displayName": "str", "id": "str", - "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, "name": "str", - "secret": bool, - "tags": ["str"], + "properties": { + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -95,15 +89,17 @@ async def test_workspace_named_value_begin_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "keyVault": {"identityClientId": "str", "secretIdentifier": "str"}, + "secret": bool, + "tags": ["str"], + "value": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) ).result() # call '.result()' to poll until service return final result @@ -118,13 +114,25 @@ async def test_workspace_named_value_delete(self, resource_group): service_name="str", workspace_id="str", named_value_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_named_value_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", + ) + 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_workspace_named_value_list_value(self, resource_group): @@ -133,7 +141,6 @@ async def test_workspace_named_value_list_value(self, resource_group): service_name="str", workspace_id="str", named_value_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -148,7 +155,6 @@ async def test_workspace_named_value_begin_refresh_secret(self, resource_group): service_name="str", workspace_id="str", named_value_id="str", - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result 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 index 517ebeb9e88c..74fa4569d033 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_notification_list_by_service(self, resource_group): - response = self.client.workspace_notification.list_by_service( + def test_workspace_notification_get(self, resource_group): + response = self.client.workspace_notification.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + notification_name="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_notification_get(self, resource_group): - response = self.client.workspace_notification.get( + def test_workspace_notification_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-05-01", ) # please add some check logic here by yourself @@ -47,14 +46,12 @@ def test_workspace_notification_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_notification_create_or_update(self, resource_group): - response = self.client.workspace_notification.create_or_update( + def test_workspace_notification_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", - notification_name="str", - api_version="2024-05-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_notification_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_operations_async.py index 5d42ad8f2e91..e29fcc83cc65 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,25 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_notification_list_by_service(self, resource_group): - response = self.client.workspace_notification.list_by_service( + async def test_workspace_notification_get(self, resource_group): + response = await self.client.workspace_notification.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + notification_name="str", ) - 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_workspace_notification_get(self, resource_group): - response = await self.client.workspace_notification.get( + async def test_workspace_notification_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-05-01", ) # please add some check logic here by yourself @@ -48,14 +47,12 @@ async def test_workspace_notification_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_notification_create_or_update(self, resource_group): - response = await self.client.workspace_notification.create_or_update( + async def test_workspace_notification_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", - notification_name="str", - api_version="2024-05-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_notification_recipient_email_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_notification_recipient_email_operations.py index b604a967e2e0..39fe6f5e150c 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_workspace_notification_recipient_email_list_by_notification(self, resou service_name="str", workspace_id="str", notification_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -41,7 +40,6 @@ def test_workspace_notification_recipient_email_check_entity_exists(self, resour workspace_id="str", notification_name="str", email="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -56,7 +54,6 @@ def test_workspace_notification_recipient_email_create_or_update(self, resource_ workspace_id="str", notification_name="str", email="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -71,7 +68,6 @@ def test_workspace_notification_recipient_email_delete(self, resource_group): workspace_id="str", notification_name="str", email="str", - api_version="2024-05-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 index 495d787477cd..c5e9a1953d11 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_workspace_notification_recipient_email_list_by_notification(self, service_name="str", workspace_id="str", notification_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -42,7 +41,6 @@ async def test_workspace_notification_recipient_email_check_entity_exists(self, workspace_id="str", notification_name="str", email="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -57,7 +55,6 @@ async def test_workspace_notification_recipient_email_create_or_update(self, res workspace_id="str", notification_name="str", email="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -72,7 +69,6 @@ async def test_workspace_notification_recipient_email_delete(self, resource_grou workspace_id="str", notification_name="str", email="str", - api_version="2024-05-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 index 45a1a9d5a23d..a65ce4707181 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,6 @@ def test_workspace_notification_recipient_user_list_by_notification(self, resour service_name="str", workspace_id="str", notification_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -41,7 +40,6 @@ def test_workspace_notification_recipient_user_check_entity_exists(self, resourc workspace_id="str", notification_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -56,7 +54,6 @@ def test_workspace_notification_recipient_user_create_or_update(self, resource_g workspace_id="str", notification_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -71,7 +68,6 @@ def test_workspace_notification_recipient_user_delete(self, resource_group): workspace_id="str", notification_name="str", user_id="str", - api_version="2024-05-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 index 6bca6d3edcc4..b6f0c7ca6cda 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -27,7 +27,6 @@ async def test_workspace_notification_recipient_user_list_by_notification(self, service_name="str", workspace_id="str", notification_name="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -42,7 +41,6 @@ async def test_workspace_notification_recipient_user_check_entity_exists(self, r workspace_id="str", notification_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -57,7 +55,6 @@ async def test_workspace_notification_recipient_user_create_or_update(self, reso workspace_id="str", notification_name="str", user_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -72,7 +69,6 @@ async def test_workspace_notification_recipient_user_delete(self, resource_group workspace_id="str", notification_name="str", user_id="str", - api_version="2024-05-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 index 26ecaee932b4..dc5f2c70f6a1 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_list_by_service(self, resource_group): - response = self.client.workspace.list_by_service( + def test_workspace_get(self, resource_group): + response = self.client.workspace.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + workspace_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -37,7 +37,6 @@ def test_workspace_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -45,12 +44,25 @@ def test_workspace_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_get(self, resource_group): - response = self.client.workspace.get( + def test_workspace_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"displayName": "str", "description": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -58,13 +70,27 @@ def test_workspace_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_create_or_update(self, resource_group): - response = self.client.workspace.create_or_update( + def test_workspace_update(self, resource_group): + response = self.client.workspace.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-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"displayName": "str", "description": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -72,14 +98,13 @@ def test_workspace_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_update(self, resource_group): - response = self.client.workspace.update( + def test_workspace_delete(self, resource_group): + response = self.client.workspace.delete( 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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -87,14 +112,11 @@ def test_workspace_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_delete(self, resource_group): - response = self.client.workspace.delete( + def test_workspace_list_by_service(self, resource_group): + response = self.client.workspace.list_by_service( resource_group_name=resource_group.name, service_name="str", - workspace_id="str", - if_match="str", - api_version="2024-05-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_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_operations_async.py index ff284b090703..5d570477206b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_list_by_service(self, resource_group): - response = self.client.workspace.list_by_service( + async def test_workspace_get(self, resource_group): + response = await self.client.workspace.get( resource_group_name=resource_group.name, service_name="str", - api_version="2024-05-01", + workspace_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -38,7 +38,6 @@ async def test_workspace_get_entity_tag(self, resource_group): resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -46,12 +45,25 @@ async def test_workspace_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_get(self, resource_group): - response = await self.client.workspace.get( + async def test_workspace_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"displayName": "str", "description": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -59,13 +71,27 @@ async def test_workspace_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_create_or_update(self, resource_group): - response = await self.client.workspace.create_or_update( + async def test_workspace_update(self, resource_group): + response = await self.client.workspace.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-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"displayName": "str", "description": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -73,14 +99,13 @@ async def test_workspace_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_update(self, resource_group): - response = await self.client.workspace.update( + async def test_workspace_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", - parameters={"description": "str", "displayName": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -88,14 +113,11 @@ async def test_workspace_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_delete(self, resource_group): - response = await self.client.workspace.delete( + async def test_workspace_list_by_service(self, resource_group): + response = self.client.workspace.list_by_service( resource_group_name=resource_group.name, service_name="str", - workspace_id="str", - if_match="str", - api_version="2024-05-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_policy_fragment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_fragment_operations.py index a33a58210ae3..83c880521700 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_policy_fragment_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_policy_fragment_get_entity_tag(self, resource_group): - response = self.client.workspace_policy_fragment.get_entity_tag( + def test_workspace_policy_fragment_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_workspace_policy_fragment_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_policy_fragment_get(self, resource_group): - response = self.client.workspace_policy_fragment.get( + def test_workspace_policy_fragment_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-05-01", ) # please add some check logic here by yourself @@ -68,15 +53,19 @@ def test_workspace_policy_fragment_begin_create_or_update(self, resource_group): workspace_id="str", id="str", parameters={ - "description": "str", - "format": "str", "id": "str", "name": "str", - "provisioningState": "str", + "properties": {"value": "str", "description": "str", "format": "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", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -90,13 +79,25 @@ def test_workspace_policy_fragment_delete(self, resource_group): service_name="str", workspace_id="str", id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_policy_fragment_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", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy def test_workspace_policy_fragment_list_references(self, resource_group): @@ -105,7 +106,6 @@ def test_workspace_policy_fragment_list_references(self, resource_group): service_name="str", workspace_id="str", id="str", - api_version="2024-05-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 index 6b35f719b6ad..039ff6a4632e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_policy_fragment_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-05-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_workspace_policy_fragment_get_entity_tag(self, resource_group): - response = await self.client.workspace_policy_fragment.get_entity_tag( + async def test_workspace_policy_fragment_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_workspace_policy_fragment_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_policy_fragment_get(self, resource_group): - response = await self.client.workspace_policy_fragment.get( + async def test_workspace_policy_fragment_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-05-01", ) # please add some check logic here by yourself @@ -70,15 +55,19 @@ async def test_workspace_policy_fragment_begin_create_or_update(self, resource_g workspace_id="str", id="str", parameters={ - "description": "str", - "format": "str", "id": "str", "name": "str", - "provisioningState": "str", + "properties": {"value": "str", "description": "str", "format": "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", + }, "type": "str", - "value": "str", }, - api_version="2024-05-01", ) ).result() # call '.result()' to poll until service return final result @@ -93,13 +82,25 @@ async def test_workspace_policy_fragment_delete(self, resource_group): service_name="str", workspace_id="str", id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_policy_fragment_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", + ) + 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_workspace_policy_fragment_list_references(self, resource_group): @@ -108,7 +109,6 @@ async def test_workspace_policy_fragment_list_references(self, resource_group): service_name="str", workspace_id="str", id="str", - api_version="2024-05-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 index 900dafb6ddd8..d5949cecaa8e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_policy_list_by_api(self, resource_group): - response = self.client.workspace_policy.list_by_api( + def test_workspace_policy_get(self, resource_group): + response = self.client.workspace_policy.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + policy_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -39,7 +39,6 @@ def test_workspace_policy_get_entity_tag(self, resource_group): service_name="str", workspace_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,26 @@ def test_workspace_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_policy_get(self, resource_group): - response = self.client.workspace_policy.get( + def test_workspace_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -61,14 +73,14 @@ def test_workspace_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_policy_create_or_update(self, resource_group): - response = self.client.workspace_policy.create_or_update( + def test_workspace_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -76,15 +88,12 @@ def test_workspace_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_policy_delete(self, resource_group): - response = self.client.workspace_policy.delete( + def test_workspace_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_policy_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_policy_operations_async.py index 6701fc5de297..f18d1e1f17ca 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_policy_list_by_api(self, resource_group): - response = self.client.workspace_policy.list_by_api( + async def test_workspace_policy_get(self, resource_group): + response = await self.client.workspace_policy.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + policy_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +40,6 @@ async def test_workspace_policy_get_entity_tag(self, resource_group): service_name="str", workspace_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,26 @@ async def test_workspace_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_policy_get(self, resource_group): - response = await self.client.workspace_policy.get( + async def test_workspace_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -62,14 +74,14 @@ async def test_workspace_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_policy_create_or_update(self, resource_group): - response = await self.client.workspace_policy.create_or_update( + async def test_workspace_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -77,15 +89,12 @@ async def test_workspace_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_policy_delete(self, resource_group): - response = await self.client.workspace_policy.delete( + async def test_workspace_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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_product_api_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations.py index 5af8056859c5..145e4b15eb7e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_api_link_list_by_product(self, resource_group): - response = self.client.workspace_product_api_link.list_by_product( + def test_workspace_product_api_link_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_version="2024-05-01", + api_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_api_link_get(self, resource_group): - response = self.client.workspace_product_api_link.get( + def test_workspace_product_api_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"apiId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -49,15 +62,13 @@ def test_workspace_product_api_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_api_link_create_or_update(self, resource_group): - response = self.client.workspace_product_api_link.create_or_update( + def test_workspace_product_api_link_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", - parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -65,15 +76,13 @@ def test_workspace_product_api_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_api_link_delete(self, resource_group): - response = self.client.workspace_product_api_link.delete( + def test_workspace_product_api_link_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_link_id="str", - api_version="2024-05-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_product_api_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_api_link_operations_async.py index d392c08eb705..9afac8e1e479 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_api_link_list_by_product(self, resource_group): - response = self.client.workspace_product_api_link.list_by_product( + async def test_workspace_product_api_link_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_version="2024-05-01", + api_link_id="str", ) - 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_workspace_product_api_link_get(self, resource_group): - response = await self.client.workspace_product_api_link.get( + async def test_workspace_product_api_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"apiId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -50,15 +63,13 @@ async def test_workspace_product_api_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_api_link_create_or_update(self, resource_group): - response = await self.client.workspace_product_api_link.create_or_update( + async def test_workspace_product_api_link_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", - parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -66,15 +77,13 @@ async def test_workspace_product_api_link_create_or_update(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_api_link_delete(self, resource_group): - response = await self.client.workspace_product_api_link.delete( + async def test_workspace_product_api_link_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_link_id="str", - api_version="2024-05-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_product_group_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations.py index 64604e98a15b..63d5c6b57cf3 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_group_link_list_by_product(self, resource_group): - response = self.client.workspace_product_group_link.list_by_product( + def test_workspace_product_group_link_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", - api_version="2024-05-01", + group_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_group_link_get(self, resource_group): - response = self.client.workspace_product_group_link.get( + def test_workspace_product_group_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"groupId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -49,15 +62,13 @@ def test_workspace_product_group_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_group_link_create_or_update(self, resource_group): - response = self.client.workspace_product_group_link.create_or_update( + def test_workspace_product_group_link_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", - parameters={"groupId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -65,15 +76,13 @@ def test_workspace_product_group_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_group_link_delete(self, resource_group): - response = self.client.workspace_product_group_link.delete( + def test_workspace_product_group_link_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", - group_link_id="str", - api_version="2024-05-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_product_group_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_group_link_operations_async.py index 350071bdfc76..5880b94d2553 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_group_link_list_by_product(self, resource_group): - response = self.client.workspace_product_group_link.list_by_product( + async def test_workspace_product_group_link_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", - api_version="2024-05-01", + group_link_id="str", ) - 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_workspace_product_group_link_get(self, resource_group): - response = await self.client.workspace_product_group_link.get( + async def test_workspace_product_group_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"groupId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -50,15 +63,13 @@ async def test_workspace_product_group_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_group_link_create_or_update(self, resource_group): - response = await self.client.workspace_product_group_link.create_or_update( + async def test_workspace_product_group_link_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", - parameters={"groupId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -66,15 +77,13 @@ async def test_workspace_product_group_link_create_or_update(self, resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_group_link_delete(self, resource_group): - response = await self.client.workspace_product_group_link.delete( + async def test_workspace_product_group_link_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", - group_link_id="str", - api_version="2024-05-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_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations.py index 69a586593427..1b2ad9016bbf 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,26 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_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-05-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_workspace_product_get_entity_tag(self, resource_group): - response = self.client.workspace_product.get_entity_tag( + def test_workspace_product_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-05-01", ) # please add some check logic here by yourself @@ -47,13 +33,12 @@ def test_workspace_product_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_get(self, resource_group): - response = self.client.workspace_product.get( + def test_workspace_product_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-05-01", ) # please add some check logic here by yourself @@ -68,18 +53,29 @@ def test_workspace_product_create_or_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "application": {"entra": {"applicationId": "str", "audience": "str"}}, + "approvalRequired": bool, + "authenticationType": ["str"], + "description": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -93,17 +89,21 @@ def test_workspace_product_update(self, resource_group): 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", + "properties": { + "application": {"entra": {"applicationId": "str", "audience": "str"}}, + "approvalRequired": bool, + "authenticationType": ["str"], + "description": "str", + "displayName": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -117,9 +117,21 @@ def test_workspace_product_delete(self, resource_group): service_name="str", workspace_id="str", product_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_workspace_product_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", + ) + 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_product_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_operations_async.py index 3f4ab6d34dbb..7cb5c74a5544 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,26 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_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-05-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_workspace_product_get_entity_tag(self, resource_group): - response = await self.client.workspace_product.get_entity_tag( + async def test_workspace_product_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-05-01", ) # please add some check logic here by yourself @@ -48,13 +34,12 @@ async def test_workspace_product_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_get(self, resource_group): - response = await self.client.workspace_product.get( + async def test_workspace_product_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-05-01", ) # please add some check logic here by yourself @@ -69,18 +54,29 @@ async def test_workspace_product_create_or_update(self, resource_group): 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", + "properties": { + "displayName": "str", + "application": {"entra": {"applicationId": "str", "audience": "str"}}, + "approvalRequired": bool, + "authenticationType": ["str"], + "description": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -94,17 +90,21 @@ async def test_workspace_product_update(self, resource_group): 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", + "properties": { + "application": {"entra": {"applicationId": "str", "audience": "str"}}, + "approvalRequired": bool, + "authenticationType": ["str"], + "description": "str", + "displayName": "str", + "state": "str", + "subscriptionRequired": bool, + "subscriptionsLimit": 0, + "terms": "str", + } }, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -118,9 +118,21 @@ async def test_workspace_product_delete(self, resource_group): service_name="str", workspace_id="str", product_id="str", - if_match="str", - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_workspace_product_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", + ) + 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_product_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_product_policy_operations.py index 38a90dff138f..5c7b100fdaf9 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,13 +20,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_policy_list_by_product(self, resource_group): - response = self.client.workspace_product_policy.list_by_product( + def test_workspace_product_policy_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", - api_version="2024-05-01", + policy_id="str", ) # please add some check logic here by yourself @@ -41,7 +41,6 @@ def test_workspace_product_policy_get_entity_tag(self, resource_group): workspace_id="str", product_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -49,14 +48,27 @@ def test_workspace_product_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_policy_get(self, resource_group): - response = self.client.workspace_product_policy.get( + def test_workspace_product_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -64,15 +76,15 @@ def test_workspace_product_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_policy_create_or_update(self, resource_group): - response = self.client.workspace_product_policy.create_or_update( + def test_workspace_product_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -80,15 +92,12 @@ def test_workspace_product_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_product_policy_delete(self, resource_group): - response = self.client.workspace_product_policy.delete( + def test_workspace_product_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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 index 7294abb1b797..a02f1bd6782b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,13 +21,13 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_policy_list_by_product(self, resource_group): - response = await self.client.workspace_product_policy.list_by_product( + async def test_workspace_product_policy_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", - api_version="2024-05-01", + policy_id="str", ) # please add some check logic here by yourself @@ -42,7 +42,6 @@ async def test_workspace_product_policy_get_entity_tag(self, resource_group): workspace_id="str", product_id="str", policy_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -50,14 +49,27 @@ async def test_workspace_product_policy_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_policy_get(self, resource_group): - response = await self.client.workspace_product_policy.get( + async def test_workspace_product_policy_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"value": "str", "format": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -65,15 +77,15 @@ async def test_workspace_product_policy_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_policy_create_or_update(self, resource_group): - response = await self.client.workspace_product_policy.create_or_update( + async def test_workspace_product_policy_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", - parameters={"format": "xml", "id": "str", "name": "str", "type": "str", "value": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -81,15 +93,12 @@ async def test_workspace_product_policy_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_product_policy_delete(self, resource_group): - response = await self.client.workspace_product_policy.delete( + async def test_workspace_product_policy_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", - policy_id="str", - if_match="str", - api_version="2024-05-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 index 6f18307877c0..5e34457535e7 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_subscription_list(self, resource_group): - response = self.client.workspace_subscription.list( + def test_workspace_subscription_get(self, resource_group): + response = self.client.workspace_subscription.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + sid="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -39,7 +39,6 @@ def test_workspace_subscription_get_entity_tag(self, resource_group): service_name="str", workspace_id="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,23 @@ def test_workspace_subscription_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_subscription_get(self, resource_group): - response = self.client.workspace_subscription.get( + def test_workspace_subscription_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", - api_version="2024-05-01", + parameters={ + "properties": { + "displayName": "str", + "scope": "str", + "allowTracing": bool, + "ownerId": "str", + "primaryKey": "str", + "secondaryKey": "str", + "state": "str", + } + }, ) # please add some check logic here by yourself @@ -61,22 +70,27 @@ def test_workspace_subscription_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_subscription_create_or_update(self, resource_group): - response = self.client.workspace_subscription.create_or_update( + def test_workspace_subscription_update(self, resource_group): + response = self.client.workspace_subscription.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", + "properties": { + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -84,25 +98,14 @@ def test_workspace_subscription_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_subscription_update(self, resource_group): - response = self.client.workspace_subscription.update( + def test_workspace_subscription_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", - 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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -110,16 +113,13 @@ def test_workspace_subscription_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_subscription_delete(self, resource_group): - response = self.client.workspace_subscription.delete( + def test_workspace_subscription_list(self, resource_group): + response = self.client.workspace_subscription.list( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - sid="str", - if_match="str", - api_version="2024-05-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -131,7 +131,6 @@ def test_workspace_subscription_regenerate_primary_key(self, resource_group): service_name="str", workspace_id="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -145,7 +144,6 @@ def test_workspace_subscription_regenerate_secondary_key(self, resource_group): service_name="str", workspace_id="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -159,7 +157,6 @@ def test_workspace_subscription_list_secrets(self, resource_group): service_name="str", workspace_id="str", sid="str", - api_version="2024-05-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 index 68eaddceb31c..cc5b6a7cce34 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_subscription_list(self, resource_group): - response = self.client.workspace_subscription.list( + async def test_workspace_subscription_get(self, resource_group): + response = await self.client.workspace_subscription.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + sid="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +40,6 @@ async def test_workspace_subscription_get_entity_tag(self, resource_group): service_name="str", workspace_id="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,23 @@ async def test_workspace_subscription_get_entity_tag(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_subscription_get(self, resource_group): - response = await self.client.workspace_subscription.get( + async def test_workspace_subscription_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", - api_version="2024-05-01", + parameters={ + "properties": { + "displayName": "str", + "scope": "str", + "allowTracing": bool, + "ownerId": "str", + "primaryKey": "str", + "secondaryKey": "str", + "state": "str", + } + }, ) # please add some check logic here by yourself @@ -62,22 +71,27 @@ async def test_workspace_subscription_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_subscription_create_or_update(self, resource_group): - response = await self.client.workspace_subscription.create_or_update( + async def test_workspace_subscription_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", parameters={ - "allowTracing": bool, - "displayName": "str", - "ownerId": "str", - "primaryKey": "str", - "scope": "str", - "secondaryKey": "str", - "state": "str", + "properties": { + "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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -85,25 +99,14 @@ async def test_workspace_subscription_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_subscription_update(self, resource_group): - response = await self.client.workspace_subscription.update( + async def test_workspace_subscription_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", - 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-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -111,16 +114,13 @@ async def test_workspace_subscription_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_subscription_delete(self, resource_group): - response = await self.client.workspace_subscription.delete( + async def test_workspace_subscription_list(self, resource_group): + response = self.client.workspace_subscription.list( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - sid="str", - if_match="str", - api_version="2024-05-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -132,7 +132,6 @@ async def test_workspace_subscription_regenerate_primary_key(self, resource_grou service_name="str", workspace_id="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -146,7 +145,6 @@ async def test_workspace_subscription_regenerate_secondary_key(self, resource_gr service_name="str", workspace_id="str", sid="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -160,7 +158,6 @@ async def test_workspace_subscription_list_secrets(self, resource_group): service_name="str", workspace_id="str", sid="str", - api_version="2024-05-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 index 38d4291b823f..331acdb753fd 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_api_link_list_by_product(self, resource_group): - response = self.client.workspace_tag_api_link.list_by_product( + def test_workspace_tag_api_link_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_version="2024-05-01", + api_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_api_link_get(self, resource_group): - response = self.client.workspace_tag_api_link.get( + def test_workspace_tag_api_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"apiId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -49,15 +62,13 @@ def test_workspace_tag_api_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_api_link_create_or_update(self, resource_group): - response = self.client.workspace_tag_api_link.create_or_update( + def test_workspace_tag_api_link_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", - parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -65,15 +76,13 @@ def test_workspace_tag_api_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_api_link_delete(self, resource_group): - response = self.client.workspace_tag_api_link.delete( + def test_workspace_tag_api_link_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_link_id="str", - api_version="2024-05-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_tag_api_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_api_link_operations_async.py index 149df5af2f2c..a073ed73b88b 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_api_link_list_by_product(self, resource_group): - response = self.client.workspace_tag_api_link.list_by_product( + async def test_workspace_tag_api_link_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_version="2024-05-01", + api_link_id="str", ) - 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_workspace_tag_api_link_get(self, resource_group): - response = await self.client.workspace_tag_api_link.get( + async def test_workspace_tag_api_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"apiId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -50,15 +63,13 @@ async def test_workspace_tag_api_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_api_link_create_or_update(self, resource_group): - response = await self.client.workspace_tag_api_link.create_or_update( + async def test_workspace_tag_api_link_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", - parameters={"apiId": "str", "id": "str", "name": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -66,15 +77,13 @@ async def test_workspace_tag_api_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_api_link_delete(self, resource_group): - response = await self.client.workspace_tag_api_link.delete( + async def test_workspace_tag_api_link_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_link_id="str", - api_version="2024-05-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_tag_operation_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations.py index 57823b6ec8e3..75d2272455e6 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_operation_link_list_by_product(self, resource_group): - response = self.client.workspace_tag_operation_link.list_by_product( + def test_workspace_tag_operation_link_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", - api_version="2024-05-01", + operation_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_operation_link_get(self, resource_group): - response = self.client.workspace_tag_operation_link.get( + def test_workspace_tag_operation_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"operationId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -49,15 +62,13 @@ def test_workspace_tag_operation_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_operation_link_create_or_update(self, resource_group): - response = self.client.workspace_tag_operation_link.create_or_update( + def test_workspace_tag_operation_link_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", - parameters={"id": "str", "name": "str", "operationId": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -65,15 +76,13 @@ def test_workspace_tag_operation_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_operation_link_delete(self, resource_group): - response = self.client.workspace_tag_operation_link.delete( + def test_workspace_tag_operation_link_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", - operation_link_id="str", - api_version="2024-05-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_tag_operation_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operation_link_operations_async.py index ef709673fd56..929886a3adb9 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_operation_link_list_by_product(self, resource_group): - response = self.client.workspace_tag_operation_link.list_by_product( + async def test_workspace_tag_operation_link_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", - api_version="2024-05-01", + operation_link_id="str", ) - 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_workspace_tag_operation_link_get(self, resource_group): - response = await self.client.workspace_tag_operation_link.get( + async def test_workspace_tag_operation_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"operationId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -50,15 +63,13 @@ async def test_workspace_tag_operation_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_operation_link_create_or_update(self, resource_group): - response = await self.client.workspace_tag_operation_link.create_or_update( + async def test_workspace_tag_operation_link_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", - parameters={"id": "str", "name": "str", "operationId": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -66,15 +77,13 @@ async def test_workspace_tag_operation_link_create_or_update(self, resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_operation_link_delete(self, resource_group): - response = await self.client.workspace_tag_operation_link.delete( + async def test_workspace_tag_operation_link_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", - operation_link_id="str", - api_version="2024-05-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_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations.py index 4608a287d894..46bb8537eed9 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,14 +20,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_list_by_service(self, resource_group): - response = self.client.workspace_tag.list_by_service( + def test_workspace_tag_get(self, resource_group): + response = self.client.workspace_tag.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + tag_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -39,7 +39,6 @@ def test_workspace_tag_get_entity_state(self, resource_group): service_name="str", workspace_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -47,13 +46,13 @@ def test_workspace_tag_get_entity_state(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_get(self, resource_group): - response = self.client.workspace_tag.get( + def test_workspace_tag_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", - api_version="2024-05-01", + parameters={"properties": {"displayName": "str"}}, ) # please add some check logic here by yourself @@ -61,14 +60,15 @@ def test_workspace_tag_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_create_or_update(self, resource_group): - response = self.client.workspace_tag.create_or_update( + def test_workspace_tag_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", - parameters={"displayName": "str"}, - api_version="2024-05-01", + parameters={"properties": {"displayName": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -76,15 +76,14 @@ def test_workspace_tag_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_update(self, resource_group): - response = self.client.workspace_tag.update( + def test_workspace_tag_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", - parameters={"displayName": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -92,15 +91,12 @@ def test_workspace_tag_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_delete(self, resource_group): - response = self.client.workspace_tag.delete( + def test_workspace_tag_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", - tag_id="str", - if_match="str", - api_version="2024-05-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_tag_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_operations_async.py index e14cbb023b58..171b7a00493d 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,14 +21,14 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_list_by_service(self, resource_group): - response = self.client.workspace_tag.list_by_service( + async def test_workspace_tag_get(self, resource_group): + response = await self.client.workspace_tag.get( resource_group_name=resource_group.name, service_name="str", workspace_id="str", - api_version="2024-05-01", + tag_id="str", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -40,7 +40,6 @@ async def test_workspace_tag_get_entity_state(self, resource_group): service_name="str", workspace_id="str", tag_id="str", - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -48,13 +47,13 @@ async def test_workspace_tag_get_entity_state(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_get(self, resource_group): - response = await self.client.workspace_tag.get( + async def test_workspace_tag_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", - api_version="2024-05-01", + parameters={"properties": {"displayName": "str"}}, ) # please add some check logic here by yourself @@ -62,14 +61,15 @@ async def test_workspace_tag_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_create_or_update(self, resource_group): - response = await self.client.workspace_tag.create_or_update( + async def test_workspace_tag_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", - parameters={"displayName": "str"}, - api_version="2024-05-01", + parameters={"properties": {"displayName": "str"}}, + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -77,15 +77,14 @@ async def test_workspace_tag_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_update(self, resource_group): - response = await self.client.workspace_tag.update( + async def test_workspace_tag_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", - parameters={"displayName": "str"}, - api_version="2024-05-01", + etag="str", + match_condition=~azure.core.MatchConditions, ) # please add some check logic here by yourself @@ -93,15 +92,12 @@ async def test_workspace_tag_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_delete(self, resource_group): - response = await self.client.workspace_tag.delete( + async def test_workspace_tag_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", - tag_id="str", - if_match="str", - api_version="2024-05-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_tag_product_link_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations.py index 0d36c7f85dc1..ecb2eb903891 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,28 +20,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_product_link_list_by_product(self, resource_group): - response = self.client.workspace_tag_product_link.list_by_product( + def test_workspace_tag_product_link_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", - api_version="2024-05-01", + product_link_id="str", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_product_link_get(self, resource_group): - response = self.client.workspace_tag_product_link.get( + def test_workspace_tag_product_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"productId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -49,15 +62,13 @@ def test_workspace_tag_product_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_product_link_create_or_update(self, resource_group): - response = self.client.workspace_tag_product_link.create_or_update( + def test_workspace_tag_product_link_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", - parameters={"id": "str", "name": "str", "productId": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -65,15 +76,13 @@ def test_workspace_tag_product_link_create_or_update(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_workspace_tag_product_link_delete(self, resource_group): - response = self.client.workspace_tag_product_link.delete( + def test_workspace_tag_product_link_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", - product_link_id="str", - api_version="2024-05-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_tag_product_link_operations_async.py b/sdk/apimanagement/azure-mgmt-apimanagement/generated_tests/test_api_management_workspace_tag_product_link_operations_async.py index f2e475a0480f..bfc2536ca52e 100644 --- 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 @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,28 +21,41 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_product_link_list_by_product(self, resource_group): - response = self.client.workspace_tag_product_link.list_by_product( + async def test_workspace_tag_product_link_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", - api_version="2024-05-01", + product_link_id="str", ) - 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_workspace_tag_product_link_get(self, resource_group): - response = await self.client.workspace_tag_product_link.get( + async def test_workspace_tag_product_link_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", - api_version="2024-05-01", + parameters={ + "id": "str", + "name": "str", + "properties": {"productId": "str"}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, ) # please add some check logic here by yourself @@ -50,15 +63,13 @@ async def test_workspace_tag_product_link_get(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_product_link_create_or_update(self, resource_group): - response = await self.client.workspace_tag_product_link.create_or_update( + async def test_workspace_tag_product_link_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", - parameters={"id": "str", "name": "str", "productId": "str", "type": "str"}, - api_version="2024-05-01", ) # please add some check logic here by yourself @@ -66,15 +77,13 @@ async def test_workspace_tag_product_link_create_or_update(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_workspace_tag_product_link_delete(self, resource_group): - response = await self.client.workspace_tag_product_link.delete( + async def test_workspace_tag_product_link_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", - product_link_id="str", - api_version="2024-05-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/pyproject.toml b/sdk/apimanagement/azure-mgmt-apimanagement/pyproject.toml index 540da07d41af..54800c9de9e5 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/pyproject.toml +++ b/sdk/apimanagement/azure-mgmt-apimanagement/pyproject.toml @@ -1,6 +1,88 @@ +[build-system] +requires = [ + "setuptools>=77.0.3", + "wheel", +] +build-backend = "setuptools.build_meta" + +[project] +name = "azure-mgmt-apimanagement" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Azure Apimanagement Management Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.9" +keywords = [ + "azure", + "azure sdk", +] +dependencies = [ + "isodate>=0.6.1", + "azure-mgmt-core>=1.6.0", + "typing-extensions>=4.6.0", +] +dynamic = [ + "version", + "readme", +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic.version] +attr = "azure.mgmt.apimanagement._version.VERSION" + +[tool.setuptools.dynamic.readme] +file = [ + "README.md", + "CHANGELOG.md", +] +content-type = "text/markdown" + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "azure", + "azure.mgmt", +] + +[tool.setuptools.package-data] +pytyped = [ + "py.typed", +] + [tool.azure-sdk-build] breaking = false mypy = false pyright = false type_check_samples = false verifytypes = false + +[packaging] +package_name = "azure-mgmt-apimanagement" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "API Management" +package_doc_id = "" +is_stable = false +is_arm = true +sample_link = "" +title = "ApiManagementClient" +need_msrestazure = false +need_azuremgmtcore = true +exclude_folders = "" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/sdk_packaging.toml b/sdk/apimanagement/azure-mgmt-apimanagement/sdk_packaging.toml deleted file mode 100644 index 6cecfcf96902..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/sdk_packaging.toml +++ /dev/null @@ -1,9 +0,0 @@ -[packaging] -package_name = "azure-mgmt-apimanagement" -package_nspkg = "azure-mgmt-nspkg" -package_pprint_name = "API Management" -package_doc_id = "" -is_stable = true -is_arm = true -sample_link = "" -title = "ApiManagementClient" diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/setup.py b/sdk/apimanagement/azure-mgmt-apimanagement/setup.py deleted file mode 100644 index 6e06a94738de..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/setup.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python - -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- - -import re -import os.path -from io import open -from setuptools import find_packages, setup - -# Change the PACKAGE_NAME only to change folder and different name -PACKAGE_NAME = "azure-mgmt-apimanagement" -PACKAGE_PPRINT_NAME = "API Management" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") -# a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace("-", ".") - -# Version extraction inspired from 'requests' -with open( - os.path.join(package_folder_path, "version.py") - if os.path.exists(os.path.join(package_folder_path, "version.py")) - else os.path.join(package_folder_path, "_version.py"), - "r", -) as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - -with open("README.md", encoding="utf-8") as f: - readme = f.read() -with open("CHANGELOG.md", encoding="utf-8") as f: - changelog = f.read() - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=readme + "\n\n" + changelog, - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python", - keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "azure", - "azure.mgmt", - ] - ), - include_package_data=True, - package_data={ - "pytyped": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "typing-extensions>=4.6.0", - "azure-common>=1.1", - "azure-mgmt-core>=1.3.2", - ], - python_requires=">=3.8", -) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/tsp-location.yaml b/sdk/apimanagement/azure-mgmt-apimanagement/tsp-location.yaml new file mode 100644 index 000000000000..aed39e2c0152 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/apimanagement/resource-manager/Microsoft.ApiManagement/ApiManagement +commit: 5038b362fae5e6f54bb6fe7e0a0d18370a946acf +repo: Azure/azure-rest-api-specs +additionalDirectories: